Apache camel 驼峰:文件操作失败:连接已关闭,无指示。。代码:421
我使用的是Camel 2.15.2和ApacheCommonsNet3.3,它们部署在Tomcat容器中 问题是,在处理了200多个文件(目录中的文件超过4000个)后,路由会停止,FTP客户端会断开连接,并注销以下消息:Apache camel 驼峰:文件操作失败:连接已关闭,无指示。。代码:421,apache-camel,apache-commons-net,camel-ftp,Apache Camel,Apache Commons Net,Camel Ftp,我使用的是Camel 2.15.2和ApacheCommonsNet3.3,它们部署在Tomcat容器中 问题是,在处理了200多个文件(目录中的文件超过4000个)后,路由会停止,FTP客户端会断开连接,并注销以下消息: [ogs.sharp-stream.com:21/root/] FtpConsumer WARN Error processing file RemoteFile[route/to/file] due to File operation
[ogs.sharp-stream.com:21/root/] FtpConsumer WARN Error processing file RemoteFile[route/to/file] due to File operation failed: Connection closed without indication.. Code: 421. Caused by: [org.apache.camel.component.file.GenericFileOperationFailedException - File operation failed: Connection closed without indication.. Code: 421]
org.apache.camel.component.file.GenericFileOperationFailedException: File operation failed: Connection closed without indication.. Code: 421
at org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:713)
at org.apache.camel.component.file.remote.FtpOperations.retrieveFileToFileInLocalWorkDirectory(FtpOperations.java:440)
at org.apache.camel.component.file.remote.FtpOperations.retrieveFile(FtpOperations.java:310)
at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:384)
at org.apache.camel.component.file.remote.RemoteFileConsumer.processExchange(RemoteFileConsumer.java:137)
at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:211)
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:175)
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:187)
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:114)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.commons.net.ftp.FTPConnectionClosedException: Connection closed without indication.
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:317)
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:294)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:483)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:608)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:582)
at org.apache.commons.net.ftp.FTP.pwd(FTP.java:1454)
at org.apache.commons.net.ftp.FTPClient.printWorkingDirectory(FTPClient.java:2658)
at org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:709)
... 15 more
在相关路线的开始处使用
从URI可以看出,我也在使用File幂等存储库。它的定义是这样的
<property name="fileStore" value="target/fileidempotent/.filestore1.dat" />
<property name="maxFileStoreSize" value="512000" />
<property name="cacheSize" value="250" />
</bean>
知道为什么在处理所有文件之前连接可能会关闭吗?我假设您的连接已从防火墙关闭。
尝试将参数maxMessagesPerPoll设置为例如150。您需要将以下参数添加到ftp/ftps url 断开连接=正确 这将导致在传输文件后断开与远程主机的连接,并在再次触发路由时尝试重新连接。
(而不是使用过时的,它可能已被远程主机/防火墙关闭)只需注意,我的驼峰URL中的disconnect=true出现了类似问题,因此这似乎是一个滑过的情况,在这种情况下,路由失败而没有任何处理错误的机会?与其他情况(如无效凭据)不同,CamelFailureEndpoint未设置,除了警告日志之外,我没有收到任何错误指示。这可能是一个愚蠢的问题,但这在ftp url中看起来如何?在我的例子中,尝试执行一个
hadoop fs-getftp://usernamer:password@123.45.6.7/path/to/some/file?disconnect=true/some/local/path
并获取没有这样的文件或目录
就像它试图获取名为path/to/some/file?disconnect=true的文件一样。建议分为两条线路,以强制断开/重新连接