On Thu, Mar 15, 2012 at 8:47 AM, developpef <src...@orange.fr> wrote: > Hello, > > I am wondering if there is a way, in a Camel route, to retrieve a kind of > "stop event" that might be sent from the context when asked for stopping? > > Actually, one of my routes is processing a loop on multiple data and does a > long-running business task for each of these data. So when I try to stop the > Camel context, it uses the default shutdown strategy with the default > timeout but always finishes by killing my process. > > So I am looking for a way to catch, within a route, a "bubbling" stop event > coming from the context that could be used in my business loop to check > after each processing if the context is asking for shutdown and cleanly stop > my tasks. >
You can check the state of CamelContext as it has a getStatus method, or use the isStopping() method. And you can then check if its stopping. There is also a isRunAllowed() method that the EIPs use themselves, so sometimes it may be easier to check this method on the CamelContext. As it will return false if Camel is stopping. Alternative there is an event notifier in Camel, that send out events. And you can then have a listener that receives the events from http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/management/event/package-summary.html There is a little example here about the events http://camel.apache.org/eventnotifier-to-log-details-about-all-sent-exchanges.html > Is this possible? > > ----- > http://developpef.blogspot.com > -- > View this message in context: > http://camel.465427.n5.nabble.com/Camel-stop-event-tp5567221p5567221.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/