Apache Camel FTP错误 [英] Apache Camel FTP error

查看:150
本文介绍了Apache Camel FTP错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一段代码,该代码从FTP输入路由到Bean进程,再到FTP输出.该过程大约需要15分钟才能完成,完成后,骆驼会尝试从FTP输入路由中删除输入文件.当前,FTP服务器抛出错误:

I am working on a piece of code that routes from FTP input to a bean process and then to FTP output. The process takes about 15 minutes to complete and when it finishes, the Camel tries to delete a input file from FTP input route. Currently the FTP server throws an error:

13 Jan 2015 18:21:26 DEBUG org.apache.camel.component.file.remote.FtpOperations.deleteFile - Deleting file: ../flex-brazil/Portal_Forn/request_appr/364/NF_4.txt
13 Jan 2015 18:21:26  WARN org.slf4j.helpers.MarkerIgnoringBase.warn - Error during commit. Exchange[org.apache.camel.component.file.GenericFileMessage@3207779]. Caused by: [org.apache.camel.component.file.GenericFileOperationFailedException - File operation failed: 421 Timeout (900 seconds): closing control connection.
FTP response 421 received.  Server closed connection.. Code: 421]
org.apache.camel.component.file.GenericFileOperationFailedException: File operation failed: 421 Timeout (900 seconds): closing control connection.
FTP response 421 received.  Server closed connection.. Code: 421
at org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:701)
at org.apache.camel.component.file.remote.FtpOperations.deleteFile(FtpOperations.java:224)
at org.apache.camel.component.file.strategy.GenericFileDeleteProcessStrategy.commit(GenericFileDeleteProcessStrategy.java:71)
at org.apache.camel.component.file.GenericFileOnCompletion.processStrategyCommit(GenericFileOnCompletion.java:124)
at org.apache.camel.component.file.GenericFileOnCompletion.onCompletion(GenericFileOnCompletion.java:80)
at org.apache.camel.component.file.GenericFileOnCompletion.onComplete(GenericFileOnCompletion.java:54)
at org.apache.camel.util.UnitOfWorkHelper.doneSynchronizations(UnitOfWorkHelper.java:100)
at org.apache.camel.impl.DefaultUnitOfWork.done(DefaultUnitOfWork.java:228)
at org.apache.camel.util.UnitOfWorkHelper.doneUow(UnitOfWorkHelper.java:61)
at org.apache.camel.processor.CamelInternalProcessor$UnitOfWorkProcessorAdvice.after(CamelInternalProcessor.java:613)
at org.apache.camel.processor.CamelInternalProcessor$UnitOfWorkProcessorAdvice.after(CamelInternalProcessor.java:581)
at org.apache.camel.processor.CamelInternalProcessor$InternalCallback.done(CamelInternalProcessor.java:240)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:173)
at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:401)
at org.apache.camel.component.file.remote.RemoteFileConsumer.processExchange(RemoteFileConsumer.java:99)
at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:201)
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:165)
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:471)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.commons.net.ftp.FTPConnectionClosedException: FTP response 421 received.  Server closed connection.
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:367)
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:697)
... 25 more

有没有什么参数可以教骆驼向FTP服务器发送Keepalive以避免这种情况?

There are any parameter to teach the Camel to send keepalives to FTP server to avoid this situation?

推荐答案

我建议将整个过程分为两条路线:

I suggest to split the whole process into two routes:

  1. 读取器路由:仅从FTP服务器读取文件.
  2. 进程和编写者路由:此路由处理传入的消息并将响应写入FTP服务器

优点是,连接将在读取和删除后关闭,无一例外. 当将新消息写回到服务器时,将创建一个新连接.

The advantage is, that the connection will be closed after reading and deleting without exception. When a new message will be written back to server a new connection will be created.

当进程异步时,第一条路由只能关闭连接.为此,您可以使用队列进行读写,例如 seda jms .

The first route can only close the connection, when the process is asynchronous. For this purpose you can use queues for reading and writing e.g. seda or jms.

这篇关于Apache Camel FTP错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆