我是Apachecamel的新手 我需要将文件从ftp位置移动到我的本地文件夹:
我正在使用以下路线执行此操作:
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();
}
}
}
我没有看到文件从FTP位置移动到我的本地文件夹, 我在这里错过了什么吗?
答案 0 :(得分:0)
在你的情况下,程序在上下文事件完全启动之前完成,因为那里没有阻塞。在这里,您可以看到如何正确运行并保持正常运行:http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html