I have an issue with the FTP2 consumer (Camel 2.19.3) failing to move files after processing them when the streamDownload
property is enabled. When it's set to false
the route works as expected but when the property is true
Camel fails to move the file(s).
The route configuration (Java DSL) looks like this:
from("ftp://{{ftp.username}}@{{ftp.host}}/{{ftp.path.in}}"
+ "?password={{ftp.password}}"
+ "&initialDelay={{ftp.check.startdelay}}"
+ "&delay={{ftp.check.delay}}"
+ "&passiveMode=true"
+ "&autoCreate=false"
+ "&startingDirectoryMustExist=true"
+ "&move={{ftp.path.out}}/${file:name}"
+ "&stepwise=false"
+ "&streamDownload=true"
)
.to("log:com.example.camel?level=info")
.to("mock:aMockEndpoint");
and here's an example of the error message I'm getting:
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot rename file: RemoteFile[abc123a.csv] to: RemoteFile[/reports/archive/abc123a.csv]
Here's a Wireshark capture that shows the interaction of a failed run when the streamDownload
setting is true
:
Response: 220 (xxx)
Request: USER xxx
Response: 331 Please specify the password.
Request: PASS xxx
Response: 230 Login successful.
Request: TYPE A
Response: 200 Switching to ASCII mode.
Request: SYST
Response: 215 UNIX Type: L8
Request: PASV
Response: 227 Entering Passive Mode (192,168,1,10,108,120).
Request: LIST reports/incoming
Response: 150 Here comes the directory listing.
FTP Data: 69 bytes
Response: 226 Directory send OK.
Request: PASV
Response: 227 Entering Passive Mode (192,168,1,10,234,184).
Request: RETR reports/incoming/abc123a.csv
Response: 150 Opening BINARY mode data connection for reports/incoming/abc123a.csv (21 bytes).
FTP Data: 21 bytes
Request: DELE /reports/archive/abc123a.csv
Response: 226 Transfer complete.
Response: 550 Delete operation failed.
Request: PWD
Response: 257 "/" is the current directory
Request: CWD /reports/archive
Response: 250 Directory successfully changed.
Request: RNFR reports/incoming/abc123a.csv
Response: 550 RNFR command failed.
Request: QUIT
Response: 221 Goodbye.
It seems like Camel is trying to delete and rename the file while it's still locked by the FTP server (i.e. being consumed by the route).
Now here's a Wireshark capture of a successful run after changing the streamDownload
setting to false
:
Response: 220 (xxx)
Request: USER xxx
Response: 331 Please specify the password.
Request: PASS xxx
Response: 230 Login successful.
Request: TYPE A
Response: 200 Switching to ASCII mode.
Request: SYST
Response: 215 UNIX Type: L8
Request: PASV
Response: 227 Entering Passive Mode (192,168,1,10,253,94).
Request: LIST reports/incoming
Response: 150 Here comes the directory listing.
FTP Data: 69 bytes
Response: 226 Directory send OK.
Request: PASV
Response: 227 Entering Passive Mode (192,168,1,10,125,167).
Request: RETR reports/incoming/abc123a.csv
Response: 150 Opening BINARY mode data connection for reports/incoming/abc123a.csv (21 bytes).
FTP Data: 21 bytes
Response: 226 Transfer complete.
Request: DELE /reports/archive/abc123a.csv
Response: 550 Delete operation failed.
Request: PWD
Response: 257 "/" is the current directory
Request: CWD /reports/archive
Response: 250 Directory successfully changed.
Request: CWD /
Response: 250 Directory successfully changed.
Request: RNFR reports/incoming/abc123a.csv
Response: 350 Ready for RNTO.
Request: RNTO /reports/archive/abc123a.csv
Response: 250 Rename successful.
Request: NOOP
Response: 200 NOOP ok.
Request: PASV
Response: 227 Entering Passive Mode (192,168,1,10,168,183).
Request: LIST reports/incoming
Response: 150 Here comes the directory listing.
Response: 226 Directory send OK.
Request: QUIT
Response: 221 Goodbye.
BTW: Changing stepwise=true
makes no difference if you're wondering.
What am I doing wrong? Is this a bug or am I trying to do something Camel doesn't support?
Regards, Matt