我试图通过使用骆驼的ftp上传文件。我的代码如下用骆驼上传ftp文件
public static void main(String... args) throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
from("file:src/data?noop=true").to("ftp://myftp.com/ftp-test/?username=drauxxx&password=mypassword");
}
});
context.start();
Thread.sleep(10000);
context.stop();
}
它连接罚款,但(你可以在日志中看到),但是当我试图来存储我得到这个错误:
[1) thread #1 - file://src/data] FileConsumer DEBUG Took 0.003 seconds to poll: src/data
[1) thread #1 - file://src/data] FileConsumer DEBUG Total 1 files to consume
[1) thread #1 - file://src/data] FileConsumer DEBUG About to process file: GenericFile[ReadMe.txt] using exchange: Exchange[ReadMe.txt]
[1) thread #1 - file://src/data] SendProcessor DEBUG >>>> Endpoint[ftp://drxxx.com/ftp-test/?password=******&username=drau9546] Exchange[ReadMe.txt]
[1) thread #1 - file://src/data] RemoteFileProducer DEBUG Not already connected/logged in. Connecting to: Endpoint[ftp://drxxx.com/ftp-test/?password=******&username=drau9546]
[1) thread #1 - file://src/data] RemoteFileProducer INFO Connected and logged in to: Endpoint[ftp://drxxx.com/ftp-test/?password=******&username=drau9546]
[1) thread #1 - file://src/data] GenericFileConverter DEBUG Read file src/data/ReadMe.txt (no charset)
[ main] DefaultCamelContext INFO Apache Camel 2.10.0 (CamelContext: camel-1) is shutting down
[ main] DefaultShutdownStrategy INFO Starting to graceful shutdown 1 routes (timeout 300 seconds)
[ main] DefaultExecutorServiceManager DEBUG Created new ThreadPool for source: [email protected] with name: ShutdownTask. -> [email protected]ccedd
[el-1) thread #2 - ShutdownTask] DefaultShutdownStrategy DEBUG There are 1 routes to shutdown
[el-1) thread #2 - ShutdownTask] DefaultShutdownStrategy DEBUG Route: route1 suspended and shutdown deferred, was consuming from: Endpoint[file://src/data?noop=true]
[el-1) thread #2 - ShutdownTask] DefaultShutdownStrategy INFO Waiting as there are still 2 inflight and pending exchanges to complete, timeout in 300 seconds.
[el-1) thread #2 - ShutdownTask] DefaultShutdownStrategy INFO Waiting as there are still 2 inflight and pending exchanges to complete, timeout in 299 seconds.
....
[1) thread #1 - file://src/data] RemoteFileProducer WARN Writing file failed with: Error writing file [ftp-test/ReadMe.txt]
[1) thread #1 - file://src/data] RemoteFileProducer DEBUG Disconnecting from: Endpoint[ftp://drxxx.com/ftp-test/?password=******&username=drau9546]
[1) thread #1 - file://src/data] DefaultErrorHandler DEBUG Failed delivery for (MessageId: ID-raccoonix-55914-1347631981229-0-1 on ExchangeId: ID-raccoonix-55914-1347631981229-0-2). On delivery attempt: 0 caught: org.apache.camel.component.file.GenericFileOperationFailedException: Error writing file [ftp-test/ReadMe.txt]
[1) thread #1 - file://src/data] GenericFileOnCompletion DEBUG Done processing file: GenericFile[ReadMe.txt] using exchange: Exchange[ReadMe.txt]
[1) thread #1 - file://src/data] GenericFileOnCompletion WARN Rollback file strategy: org.apache[email protected]2c31f2a7 for file: GenericFile[ReadMe.txt]
[1) thread #1 - file://src/data] FileUtil DEBUG Retrying attempt 0 to delete file: /home/andrea/workspace/transfer/src/data/ReadMe.txt.camelLock
[1) thread #1 - file://src/data] FileUtil DEBUG Tried 1 to delete file: /home/andrea/workspace/transfer/src/data/ReadMe.txt.camelLock with result: true
[1) thread #1 - file://src/data] DefaultErrorHandler ERROR Failed delivery for (MessageId: ID-raccoonix-55914-1347631981229-0-1 on ExchangeId: ID-raccoonix-55914-1347631981229-0-2). Exhausted after delivery attempt: 1 caught: org.apache.camel.component.file.GenericFileOperationFailedException: Error writing file [ftp-test/ReadMe.txt]
是否有一些具体的参数为了正确的文件传输? 是一个ftp服务器相关的问题?
搭起一个本地ftp服务器并查看日志中的问题。这是第一件要做的事情,我会说 –
是的,以及主动和被动模式。如果文件传输模式是ASCII或BINARY。在Camel的ftp组件上有一些选项来配置它:http://camel.apache.org/ftp2。也可以尝试从一个ftp客户端来查看是否可以使用该用户/密码组合来上传文件。 –
并检查此常见问题解答如何让应用程序继续运行:http://camel.apache.org/running-camel-standalone.html,特别是此链接:http://camel.apache.org/running-camel-standalone-和具备的,它-保running.html。 –