4

我设法建立了一个 Mule 项目来从 FTP 下载文件,并将其保存在本地磁盘上。但是,在传输文件后,Mule 不断尝试删除 FTP 上的远程文件。有没有办法告诉Mule不要删除原始文件并保持原样?

这是我的项目 XML:

     <?xml version="1.0" encoding="UTF-8"?>
  <mule ...>

    <flow name="copy-remote-fileFlow1" doc:name="copy-remote-fileFlow1">
        <ftp:inbound-endpoint host="ftp.secureftp-test.com" port="21" path="subdir1" user="test" password="test" pollingFrequency="60000" responseTimeout="10000" doc:name="FTP">
            <file:filename-wildcard-filter pattern="box.ico" />
        </ftp:inbound-endpoint>
        <file:outbound-endpoint path="I:\test\" outputPattern="fromMule.ico" responseTimeout="10000"
 doc:name="File" />     </flow>

 </mule>

就我而言,我无权删除该文件,因此出现异常:

ERROR 2013-05-24 17:35:47,286 [[copy-remote-file].connector.ftp.mule.default.receiver.02] org.mule.exception.DefaultSystemExceptionStrategy: Caught exception in Exception Strategy: Failed to delete file box.ico. Ftp error: 550
java.io.IOException: Failed to delete file box.ico. Ftp error: 550
    at org.mule.transport.ftp.FtpMessageReceiver.postProcess(FtpMessageReceiver.java:202)
    at com.mulesoft.mule.transport.ftp.EEFtpMessageReceiver.postProcess(EEFtpMessageReceiver.java:71)
    at org.mule.transport.ftp.FtpMessageReceiver$FtpWork.run(FtpMessageReceiver.java:316)
    at org.mule.work.WorkerContext.run(WorkerContext.java:311)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
4

3 回答 3

6

您唯一的选择在于扩展org.mule.transport.ftp.FtpMessageReceiver以覆盖该postProcess方法,该方法负责删除 FTP 服务器上的文件。

要注册您的自定义,请FtpMessageReceiver使用service-overridesFTP 连接器上的配置元素:

<ftp:connector name="nonDeletingFtpConnector">
    <service-overrides messageReceiver="com.amce.NonDeletingFtpMessageReceiver" />
</ftp:connector>
于 2013-05-27T16:44:44.737 回答
1

在大卫已经提到的内容中添加一些内容。NonDeletingFtpMessageReceiver 类构造函数应如下所示:

public NonDeletingFtpMessageReceiver(EEFtpConnector connector,
        Flow flowConstruct, DefaultInboundEndpoint endpoint,
        long frequency, String value1, String value2, long value3)
        throws CreateException {
    super(connector, flowConstruct, endpoint, frequency);

}
于 2014-05-12T05:24:33.943 回答
0

另一种解决方案是streaming="true"在 FTP 连接器上设置禁用文件删除。

于 2015-05-19T09:21:23.290 回答