简体   繁体   中英

Camel: Stop a timer route after the processing is complete

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM