2

我有几天,看看 apache Camel 并通过 sftp 服务器将文件传输到 jms 队列或主题。

我在配置端点(消费者)和路由(从文件到 sftp,从 sftp 到 jms .....)的级别上遇到了问题。没有什么对我有用。我在 sftp 服务器(linux)上工作,java 版本“1.7.0_45”我使用 apache camel 2.5,activemq 5.3.2,我上传了 Jsch jar,

这是我的简单代码

public class FtpJms {

    public static void main(String args[]) throws Exception {
        CamelContext context = new DefaultCamelContext();
        context.addRoutes(new RouteBuilder() {
             @Override
            public void configure() {

            from("file://usr/dir1/dir2?noop=true").
            to("sftp://root@hostname/inbox?username=root&password=xxx");
        }});

我将我的程序打包成一个 jar 文件,然后在服务器上运行它。但是,它返回:

[ - file://usr/dir1/dir2] SftpOperations                 INFO  JSCH -> Authentications that can continue: password
[ - file://usr/dir1/dir2] SftpOperations                 INFO  JSCH -> Next authentication method: password
[ - file://usr/dir1/dir2] SftpOperations                 INFO  JSCH -> Authentication succeeded (password).
[ - file://usr/dir1/dir2] SftpOperations                 INFO  Connected to sftp://root@hostname:22
[ - file://usr/dir1/dir2] RemoteFileProducer             INFO  Connected and logged in to: Endpoint[sftp://root@hostname/inbox?password=******&username=root]
[ - file://usr/dir1/dir2] RemoteFileProducer             WARN  Writing file failed with: Cannot store file: inbox/test10.txt
[ - file://usr/dir1/dir2] SftpOperations                 INFO  JSCH -> Disconnecting from hostname port 22
[ - file://usr/dir1/dir2] GenericFileOnCompletion        ERROR Caused by: [org.apache.camel.component.file.GenericFileOperationFailedException - Cannot store file: inbox/test10.txt]
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot store file: inbox/test10.txt
        at org.apache.camel.component.file.remote.SftpOperations.storeFile(SftpOperations.java:617)[jar:rsrc:camel-ftp-2.5.0.jar!/:]
        at org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:220)[jar:rsrc:camel-core-2.5.0.jar!/:]
        at org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:138)[jar:rsrc:camel-core-2.5.0.jar!/:]
        at org.apache.camel.component.file.remote.RemoteFileProducer.process(RemoteFileProducer.java:49)[jar:rsrc:camel-ftp-2.5.0.jar!/:]
        at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)[jar:rsrc:camel-core-2.5.0.jar!/:]
4

0 回答 0