Reputation: 313
I have a requirement to process the big file using these 2 case (1) Pull from file directory and push to FTP (2) Pull from one FTP and push to another FTP
I am creating a java maven dependency project which use camel components to process above use-case of file transfer, so I decided to use org.apache.camel.main.Main class to start my route, but the problem is my program is not getting closed even after file is processed successfully. Somewhere I read that using "System.exit()" would solve the problem but still problem exists.
My code-
Main camelMain = new Main();
camelMain.enableHangupSupport();
camelMain.addRouteBuilder(getRouteBuilderLocaltoFTP());
camelMain.run();
RouteBuilder
public void configure() throws Exception {
from(<File-Path>).routeId("local-to-ftp")
.onCompletion().process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getContext().stop();
}
})
.toD(<FTP-Path>);
Also tried using control-Bus .toF("controlbus:route?routeId=%s&action=stop&async=true", "local-to-ftp")
But in both the cases, routes are shutting down gracefully not closing the program.
Seek help in this.
Upvotes: 0
Views: 769
Reputation: 55540
You can configure on the main to shutdown the application after X period of time, or after processing N number of messages. And you can set both of them AFAIR, eg shutdown after 2 minutes, and after 1 message processed.
Just check the methods on camelMain
. Mind that this requires a recent version of Apache Camel.
Upvotes: 1