You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by developpef <sr...@orange.fr> on 2012/03/15 08:47:14 UTC

Camel stop() event

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. 

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.

Re: Camel stop() event

Posted by developpef <sr...@orange.fr>.
OK I will use this. 

Thanks for your help!

-----
http://developpef.blogspot.com
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-stop-event-tp5567221p5567604.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel stop() event

Posted by Claus Ibsen <cl...@gmail.com>.
if (ServiceStatus.Stopping == camelContext.getStatus()) {
  ...
}


On Thu, Mar 15, 2012 at 10:58 AM, developpef <sr...@orange.fr> wrote:
> Sorry for the mistake, I meant ' Nothing more interesting on "getContext()"
> '.
>
> I think I do not really understand. Where is this "isStopping()" method? In
> 2.9.0 it is not on CamelContext :
> http://www.jarvana.com/jarvana/view/org/apache/camel/camel-core/2.9.0/camel-core-2.9.0.jar!/org/apache/camel/CamelContext.class?classDetails=ok
>
>
>
> -----
> http://developpef.blogspot.com
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-stop-event-tp5567221p5567513.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Camel stop() event

Posted by developpef <sr...@orange.fr>.
Sorry for the mistake, I meant ' Nothing more interesting on "getContext()"
'.

I think I do not really understand. Where is this "isStopping()" method? In
2.9.0 it is not on CamelContext :
http://www.jarvana.com/jarvana/view/org/apache/camel/camel-core/2.9.0/camel-core-2.9.0.jar!/org/apache/camel/CamelContext.class?classDetails=ok



-----
http://developpef.blogspot.com
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-stop-event-tp5567221p5567513.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel stop() event

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Mar 15, 2012 at 10:30 AM, developpef <sr...@orange.fr> wrote:
> Thank you for the answer.
>
> The EventNotifier seems to match my needs, but I have none of the mentioned
> methods on the context or on the status. I am in version 2.9.0 and on
> getContext().getStatus() I only found, among others, "isStarting()",
> "isStarted()", "isStoppable()" but not "isStopping()". Nothing more
> interesting on "getStatus()". Is this in an other camel's version?
>

isStopping() should be a method on CamelContext itself.


> -----
> http://developpef.blogspot.com
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-stop-event-tp5567221p5567451.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Camel stop() event

Posted by developpef <sr...@orange.fr>.
Thank you for the answer. 

The EventNotifier seems to match my needs, but I have none of the mentioned
methods on the context or on the status. I am in version 2.9.0 and on
getContext().getStatus() I only found, among others, "isStarting()",
"isStarted()", "isStoppable()" but not "isStopping()". Nothing more
interesting on "getStatus()". Is this in an other camel's version?

-----
http://developpef.blogspot.com
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-stop-event-tp5567221p5567451.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel stop() event

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Mar 15, 2012 at 8:47 AM, developpef <sr...@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: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/