Ich versuchte Apache Kamel in Beispielen für ftp gebaut und mit springboot
integrieren. Wenn ich keine ausführe, erhalte ich eine Fehlermeldung, nicht den Download der Datei. Im Folgenden finden Sie das Code-Snippet und die Protokolle. Aus den Logs konnte ich sehen, dass der Server erfolgreich verbunden ist, aber ich kann die Datei nicht im Ordner /tmp/
sehen.FTP funktioniert nicht in Apache Kamel
2016-03-18 15:21:02.744 INFO 2103 --- [ main] o.a.camel.spring.SpringCamelContext : Apache Camel 2.16.2 (CamelContext: camel-1) is starting
2016-03-18 15:21:02.744 INFO 2103 --- [ main] o.a.c.m.ManagedManagementStrategy : JMX is enabled
2016-03-18 15:21:02.805 INFO 2103 --- [ main] o.a.c.i.DefaultRuntimeEndpointRegistry : Runtime endpoint registry is in extended mode gathering usage statistics of all incoming and outgoing endpoints (cache limit: 1000)
2016-03-18 15:21:02.883 INFO 2103 --- [ main] o.a.camel.spring.SpringCamelContext : AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance.
2016-03-18 15:21:02.883 INFO 2103 --- [ main] o.a.camel.spring.SpringCamelContext : StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
2016-03-18 15:21:03.711 WARN 2103 --- [ main] o.a.c.c.file.remote.SftpOperations : JSCH -> Permanently added '**<XXXXXX>**' (RSA) to the list of known hosts.
2016-03-18 15:21:09.025 INFO 2103 --- [ main] o.a.c.c.file.remote.SftpOperations : Connected to sftp://*****@*****:22
2016-03-18 15:21:09.058 INFO 2103 --- [ main] o.a.camel.spring.SpringCamelContext : Route: route1 started and consuming from: Endpoint[sftp://******:22/tmp/sample.txt?password=xxxxxx&username=*****]
2016-03-18 15:21:09.059 INFO 2103 --- [ main] o.a.camel.spring.SpringCamelContext : Total 1 routes, of which 1 is started.
2016-03-18 15:21:09.059 INFO 2103 --- [ main] o.a.camel.spring.SpringCamelContext : Apache Camel 2.16.2 (CamelContext: camel-1) started in 6.316 seconds
2016-03-18 15:21:09.105 INFO 2103 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-03-18 15:21:09.106 INFO 2103 --- [ main] o.apache.camel.spring.boot.FatJarRouter : Started FatJarRouter in 10.232 seconds (JVM running for 10.651)
Und der Code:
@SpringBootApplication
public class MySpringBootRouter extends FatJarRouter {
@Override
public void configure() throws Exception{
// configure properties component
PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class);
pc.setLocation("classpath:ftp.properties");
// lets shutdown faster in case of in-flight messages stack up
getContext().getShutdownStrategy().setTimeout(10);
from("sftp://<mylinuxserver>:22/tmp/sample.txt?username=abc&password=123")
.to("file:/tmp/sample.txt")
.log("Downloaded file ${file:name} complete.");
System.out.println("*********************************************************************************");
// System.out.println("Camel will route files from the FTP server: "
// + getContext().resolvePropertyPlaceholders("{{ftp.server}}") + " to the target/download directory.");
System.out.println("You can configure the location of the ftp server in the src/main/resources/ftp.properties file.");
System.out.println("Use ctrl + c to stop this application.");
System.out.println("*********************************************************************************");
}
}
Das * sftp * Sie verwenden, wechseln Sie am besten das 'ftp'-Tag für' ssh'. Die Protokolldatei würde von der Formatierung profitieren. –