I have a standalone Camel application that is executed by an external task scheduler. Because of this, it needs to exit once execution is finished. To accomplish this, I'm passing the command line argument -dm 1
to process a single message before shutting down.
The application is being used to consume files in a directory
from(file("SomeDirectory").include("TestFile.*"))
.to(...);
The problem I'm running into is that each file is processed as a unique message, so the -dm 1
argument causes the application to exit after processing 1 file.
How can I get the application to exit after processing the full list of files given by TestFile.*
?
Since the File component is a batch consumer, you can inspect the exchange property called
CamelBatchComplete
. If the value istrue
, there no more files to process, so you can stop theCamelContext
. This could be as simple ascamelContext.stop()
, but see this question for more options.How can I shutdown a standalone Apache Camel application in an automated way?
Edit: Since you have a standalone application, if you're using Camel main you can use the
camel.main.durationMaxIdle​Seconds
option. Spring Boot has a similar setting.