Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用camel上传ftp文件_Ftp_Apache Camel - Fatal编程技术网

使用camel上传ftp文件

使用camel上传ftp文件,ftp,apache-camel,Ftp,Apache Camel,我正在尝试使用camel通过ftp上传文件。我的代码如下 public static void main(String... args) throws Exception { CamelContext context = new DefaultCamelContext(); context.addRoutes(new RouteBuilder() { @Override public void configure() {

我正在尝试使用camel通过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: org.apache.camel.impl.DefaultShutdownStrategy@77addb59 with name: ShutdownTask. -> org.apache.camel.util.concurrent.RejectableThreadPoolExecutor@bdccedd
[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.camel.component.file.strategy.GenericFileRenameProcessStrategy@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服务器相关问题吗?

试试看

from("file:src/data?noop=true").to("ftp://drauxxx@myftp.com/ftp-test/?password=mypassword");
除去

context.stop();
因为这是一个实验性的代码,所以您不需要它


还要检查您正在连接的FTP用户的用户权限。

安装本地FTP服务器,并在日志中查找问题。这是要做的第一件事,我想说是的,还有主动和被动模式。如果文件传输模式是ASCII或二进制。驼峰ftp组件上有一些选项可用于配置:。还可以从ftp客户端尝试,查看是否可以使用该用户/密码组合上载文件。并查看此常见问题解答如何保持应用程序运行:,尤其是此链接:。感谢您的回复。它现在似乎可以工作了,但在不同的ftp服务器上。面对同样的问题-我可以知道这个问题是如何解决的吗??