Apache Camel SFTP下载无效

时间:2017-07-28 06:49:24

标签: java spring-boot apache-camel sftp

我正在尝试从SFTP服务器位置下载文件但是日志看起来很好,最后没有任何内容从服务器下载到本地。也没有错误。请提前感谢您的输入。

可用的SFTP文件:

[root@rsysftp test1]# ls /tmp/files/test1
test1.txt  test2.txt  test3.txt  test4.txt

路由器:

@Component
public class SampleCamelRouter extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        getContext().getShutdownStrategy().setTimeout(10);

        from("sftp://ftpuser1@some.ip.value.here/tmp/files/test1?password=pass")
                .to("file:C:/out")
                .log("Downloaded file ${file:name} complete.");
    }

}

日志:

o.a.camel.spring.SpringCamelContext      : Route: route1 started and consuming from: sftp://ftpuser1@some.ip.value.here/tmp/files/test1/test1.txt?password=xxxxxx
o.a.camel.spring.SpringCamelContext      : Total 1 routes, of which 1 are started.
o.a.camel.spring.SpringCamelContext      : Apache Camel 2.18.1 (CamelContext: SampleCamel) started in 30.871 seconds
s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
c.camel.examples.SampleCamelApplication  : Started SampleCamelApplication in 37.837 seconds (JVM running for 38.891)

的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.springframework</groupId>
    <artifactId>gs-spring-boot</artifactId>
    <version>0.1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.5.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring-boot-starter</artifactId>
            <version>2.18.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-stream-starter</artifactId>
            <version>2.18.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-ftp</artifactId>
            <version>2.18.1</version>
        </dependency>

        <dependency>
            <groupId>io.hawt</groupId>
            <artifactId>hawtio-springboot</artifactId>
            <version>2.0.0</version>
        </dependency>

    </dependencies>


    <properties>
        <java.version>1.8</java.version>
    </properties>


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

1 个答案:

答案 0 :(得分:0)

文件正在从服务器上成功下载,但位置不同,所以没有文件就无法下载。

Location from download :ftpuser1@some.ip.value.here/tmp/uta/test1
Location from downloaded:ftpuser1@some.ip.value.here/home/user/tmp/uta/test1

它正在用户主目录中创建上传目录,这是它在预期目录中不可用的原因。