Mule ESB Community Edition 3.4 - prevent deletion of the source file

I was able to create a Mule project to download a file from FTP and save it to a local drive. However, after the file is transferred, Mule tries to delete the deleted file to FTP. Is there any way to tell Mule not to delete the original file and just leave it as it is?

Here is my XML project:

<?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> 

And in my case, I do not have permission to delete the file, so I get an exception:

 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
source share
3 answers

Your only option is to extend org.mule.transport.ftp.FtpMessageReceiver to override the postProcess method, which is the one that takes care of deleting the file on the FTP server.

To register a custom FtpMessageReceiver use the service-overrides configuration item on your FTP connector:

 <ftp:connector name="nonDeletingFtpConnector"> <service-overrides messageReceiver="com.amce.NonDeletingFtpMessageReceiver" /> </ftp:connector> 
+6
source

Adding a few things to what David already mentioned. The constructor of the NonDeletingFtpMessageReceiver class should look like this:

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

Another solution is to set streaming="true" to the FTP connector, which will disable file deletion.

0
source

Source: https://habr.com/ru/post/1482600/


All Articles