Reputation: 12149
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. 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. I have tested the ftp connection with an ftp client and it all works ok.
When I run it it moves the file into a directory called ".camel" but does not upload it? 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()?
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
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://[email protected]/home/rob/test/?password=rob")
.otherwise()
.to("log://org.apache.camel.howto?showAll=true&level=DEBUG");
}
}
Upvotes: 1
Views: 4790
Reputation: 12149
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://[email protected]: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.
Upvotes: 4