[英]Apache camel - simple scan directory and ftp upload
I am trying to use Apache camel to do a simple listen of a directory and upload the files via ftp onto an external location. 我正在尝试使用Apache骆驼对目录进行简单的侦听,并通过ftp将文件上传到外部位置。 I am new this.
我是新来的。
I can move my files from one directory to another with this script. 我可以使用此脚本将文件从一个目录移动到另一个目录。 So figured I am half way there.
所以我想我已经走了一半。 I am now struggling to move it from one directory to the ftp server directory.
我现在正努力将其从一个目录移动到ftp服务器目录。 I have tested the ftp connection with an ftp client and it all works ok.
我已经用ftp客户端测试了ftp连接,并且一切正常。
When I run it it moves the file into a directory called ".camel" but does not upload it? 当我运行它时,它将文件移动到名为“ .camel”的目录中,但不上传吗? Its not outputting any error?
它没有输出任何错误? I am not sure output or view the logs to the terminal so I can view what went wrong?
我不确定向终端输出或查看日志,因此我可以查看出了什么问题? Do I need to include some kind of .process()?
我是否需要包括某种.process()?
Main.class 主类
public class Main {
public static void main(String[] args) throws Exception{
CamelContext camelContext = new DefaultCamelContext();
camelContext.addRoutes(new MoveFileRoute());
camelContext.start();
Thread.sleep(10000);
camelContext.stop();
}
}
MoveFileToRoute MoveFileToRoute
public class MoveFileRoute extends RouteBuilder {
@Override
public void configure() throws Exception{
from("file://C:\\test")
.choice()
.when(simple("${in.header.CamelFileName} contains '*.xlsx'"))
.to("ftp://rob@10.171.16.100/home/rob/test/?password=rob")
.otherwise()
.to("log://org.apache.camel.howto?showAll=true&level=DEBUG");
}
}
Figured it out.. 弄清楚了..
.when(simple("${in.header.CamelFileName} contains '*.xlsx'"))
The *
on this line breaks it.. 这行上的
*
打破了它。
Answer here 在这里回答
public class MoveFileRoute extends RouteBuilder {
@Override
public void configure() throws Exception{
from("file://C:\\test")
.choice()
.when(simple("${in.header.CamelFileName} contains '.xlsx'"))
.to("ftp://rob@10.171.16.100:21/test?password=rob")
.otherwise()
.to("log://org.apache.camel.howto?showAll=true&level=DEBUG");
}
}
I still havent figured out how to view the logs yet though. 我仍然还没有想出如何查看日志。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.