简体   繁体   English

Apache Camel SFTP下载无法正常工作

[英]Apache Camel SFTP download is not working

I am trying to download file from SFTP server location but log looks good finally nothing is downloaded from the server to local.No errors also coming.Please give your inputs thanks in advance. 我正在尝试从SFTP服务器位置下载文件,但日志看起来很好,最后没有任何内容从服务器下载到本地。也没有错误出现。请事先感谢您的输入。

SFTP files available: 可用的SFTP文件:

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

Router: 路由器:

@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.");
    }

}

Log: 日志:

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 的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>

File is downloading from the Server successfully but location is different so without files it is not able to download. 文件已成功从服务器下载,但是位置不同,因此如果没有文件,则无法下载。

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

It is creating the uploading directory inside the user home directory that is the reason it is not available in expected directory. 它正在用户主目录中创建上载目录,这是其在预期目录中不可用的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM