[英]move file from ftp to local using apachecamel
I am new to Apachecamel I have a requirement to move a file from ftp location to my local folder: 我是Apachecamel的新手,我需要将文件从ftp位置移动到本地文件夹:
I am using below route to do this: 我正在使用下面的路线来做到这一点:
import java.io.File;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
public class CopyFtp {
public static void main(final String[] arguments) {
final CamelContext camelContext = new DefaultCamelContext();
/*
* ConnectionFactory connectionFactory = new
* ActiveMQConnectionFactory("admin", "admin",
* ActiveMQConnection.DEFAULT_BROKER_URL);
* camelContext.addComponent("test-jms",
* JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
*/
try {
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("ftp://user@server.com/folder?password=abc&delay=10000").routeId("testRoute")
.process(new Processor() {
@Override
public void process(Exchange msg) throws Exception {
File file = msg.getIn().getBody(File.class);
String file1 = msg.getIn().getBody(String.class);
System.out.println("" + file + file1);
}
}).to("file://E:/TestingWatch1/output");
}
});
camelContext.start();
// Thread.sleep(10*60*1000);
// camelContext.stop();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
I don't see file is moving from FTP location to my local folder, am I missing something here? 我没有看到文件从FTP位置移动到本地文件夹,我在这里丢失了什么吗?
In your case program is finished before context event fully started as there are no blocking there. 在您的情况下,在上下文事件完全开始之前,程序已完成,因为那里没有阻塞。 Here you can see how to run it properly and leave running: http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html
在这里,您可以查看如何正常运行并保持运行状态: http : //camel.apache.org/running-camel-standalone-and-have-it-keep-running.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.