Reputation: 674
I am adding routes dynamically using "timer" component with "repeatCount=1" to add a route. I need to stop this route once it has completed this run.
from("timer://" + host + "-Compressor?delay=10000&repeatCount=1")
.process(.....)
.to("mock:test");
Here, host is a variable used when adding the route dynamically. The route needs to be stopped so as to spawn it again when required. What am not able to do is how to know if the route has no pending messages. For GenericFileConsumer, there is a method "getPendingExchangesSize()". But I didn't get anything similar for this component.
Moreover, the timer component is just used to kick start the route without requirement of any external simulation and it has option to run it just once.
Upvotes: 2
Views: 2536
Reputation: 55525
See the controlbus eip pattern. You can route to an endpoint to stop a route.
You may want to do this with 'async=true' as you would stop the route you are currently routing, which wont work to well in synchronous mode as Camel will attempt to complete the inflight messages of the routes before stopping in graceful manner
Upvotes: 2