You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Vishal Changrani <vi...@ericsson.com> on 2012/11/09 20:26:59 UTC

Forcefully shutting down routes...

Hi,

I am trying to shutdown a route by calling route.
Camelcontext.stopRoute(routeId, 0, TimeUnit.SECONDS, false / true); //tried both true and false

However the route continues to persist sometimes and I get the following messages..

DEBUG - Route: Publisher_21 suspended and shutdown deferred, was consuming from: Endpoint[timer://TIMER_FOR_PUBLISHER?daemon=true&fixedRate=true&period=60000]
INFO - Waiting as there are still 1 inflight and pending exchanges to complete, timeout in 0 seconds.
INFO - Waiting as there are still 1 inflight and pending exchanges to complete, timeout in -1 seconds.
......

(On the route orignally I had set .shutdownRoute(default);)

I understand that the route may indeed be busy processing messages but I really know what I am doing and want to force it to stop.

I read a few posts related to this issue but am still a little lost. I am running Camel 2.9.2 and is there no way that the route's process can be just interrupted ?

Thanks,
V




Re: Forcefully shutting down routes...

Posted by lleclerc <ll...@aim-rg.com>.
I just got this problem and found the solution with this line : 

Camelcontext.stopRoute(routeId, 1, TimeUnit.SECONDS, false);

You want false to force the shutdown and you need 1 to prevent the following
problem : 

[org.apache.camel.impl.DefaultShutdownStrategy] : Waiting as there are still
3 inflight and pending exchanges to complete, timeout in -1 seconds.
[org.apache.camel.impl.DefaultShutdownStrategy] : Waiting as there are still
3 inflight and pending exchanges to complete, timeout in -2 seconds.
[org.apache.camel.impl.DefaultShutdownStrategy] : Waiting as there are still
3 inflight and pending exchanges to complete, timeout in -3 seconds.

Creating a JIRA ticket now...




--
View this message in context: http://camel.465427.n5.nabble.com/Forcefully-shutting-down-routes-tp5722447p5732125.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Forcefully shutting down routes...

Posted by Ra...@cognizant.com.
No idea but asynchronous will free up the thread to do other tasks and not cause the error that there are in flight messages.

Here is the camel guide :

"Notice: As Camel always returns a Future handle for Async messaging to the client. The client can use this handler to get hold of the status of the processing whether the task is complete or an Exception occured during processing. Note that the client is not required to do so, its perfect valid to just ignore the Future handle.
        In case you want to know whether the Async Request Only failed, then you can use the Future handle and invoke get() and if it throws a ExecutionException then the processing failed. The caused exception is wrapped. You can invoke isDone() first to test whether the task is done or still in progress. Otherwise invoking get() will wait until the task is done."

So basically, if you estimate your EJB to take one hour to complete, then invoke isDone() and check the status code whether you want to proceed further with the route.



-----Original Message-----
From: vishal1981 [mailto:vishal.changrani@ericsson.com]
Sent: Monday, November 12, 2012 8:57 AM
To: users@camel.apache.org
Subject: RE: Forcefully shutting down routes...

Thanks for the reply.
Is there a reason why one should not block on an EJB for that long? Idea for
the async processing is great but then again I will have to introduce some
kind of mechanism to wait till the processor is done to invoke the next
processor in the route. There are processors which are before the EJB (such
as XML validation etc) and processors which are after the EJB processors
(e.g. other EJBs, FTP producer etc.) Synchronous (single threaded model)
really suits my application.

I am contemplating the following,
1. Subclassing the DefaultShutdownStrategy and just before calling
super.doShutdown() remove all exchanges belonging to this route from the
repository.
2. The defaultShutdownstrategy would then stop my ejb consumer. (What
happens to the Timer thread which is running that consumer is yet to be
determined; I am hoping the thread is unaffected).

-v-



--
View this message in context: http://camel.465427.n5.nabble.com/Forcefully-shutting-down-routes-tp5722447p5722560.html
Sent from the Camel - Users mailing list archive at Nabble.com.
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful.

RE: Forcefully shutting down routes...

Posted by vishal1981 <vi...@ericsson.com>.
Thanks for the reply.
Is there a reason why one should not block on an EJB for that long? Idea for
the async processing is great but then again I will have to introduce some
kind of mechanism to wait till the processor is done to invoke the next
processor in the route. There are processors which are before the EJB (such
as XML validation etc) and processors which are after the EJB processors
(e.g. other EJBs, FTP producer etc.) Synchronous (single threaded model)
really suits my application.

I am contemplating the following,
1. Subclassing the DefaultShutdownStrategy and just before calling
super.doShutdown() remove all exchanges belonging to this route from the
repository.
2. The defaultShutdownstrategy would then stop my ejb consumer. (What
happens to the Timer thread which is running that consumer is yet to be
determined; I am hoping the thread is unaffected).

-v-



--
View this message in context: http://camel.465427.n5.nabble.com/Forcefully-shutting-down-routes-tp5722447p5722560.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Forcefully shutting down routes...

Posted by Ra...@cognizant.com.
Hmm from what I understand you should not block on the EJB for so long. You may ignore the future or check later on these futures, I guess.

http://camel.apache.org/async.html

"On the other hand the asynchronous version is where the caller sends a message to an Endpoint and then returns immediately back to the caller. The message however is processed in another thread, the asynchronous thread. Then the caller can continue doing other work and at the same time the asynchronous thread is processing the message"

. The client sends an Async Request Reply message over HTTP to Camel. The control is immediately returned to the client application, that can continue and do other work while Camel routes the message.
2. Camel invokes an external TCP service using synchronous Request Reply. The client application can do other work simultaneously.
3. The client wants to get the reply so it uses the Future handle it got as response from step 1. With this handle it retrieves the reply, wait if nessasary if the reply is not ready.



-----Original Message-----
From: vishal1981 [mailto:vishal.changrani@ericsson.com]
Sent: Monday, November 12, 2012 6:01 AM
To: users@camel.apache.org
Subject: Re: Forcefully shutting down routes...

Thanks for all your replies so far.
Allow me to explain you my use case a little more in detail...
As part of my route I am using the EJB endpoint. All that the EJB does is
that it calls a stored procedure. The stored procedure takes a long time to
execute (in the order of two to three hours). My routes are created and
destroyed via a UI. Most of the time the routes will remain un-change once
defined by the user. However there could be cases where the user wants to
change the route. In this case I currently stop the route, remove the route
and then re-create a route based on his new definition.

Now, because of the long stored proc and for the fact that EJB component is
not shutdownaware I keep seeing those messages - "Waiting as there are still
1 inflight and pending exchanges to complete, timeout in -49 seconds." till
the whole stored proc finishes.

In such cases I want to just stop the stored proc and the endpoint. My
database transactions will ensure my data integrity is not compromised.

Whats more confusing is that the EJB component gets called as pat of a Time
thread shared by other routes. I dont want to interrupt the time thread
since other routes will stop as well.

Sorry for being verbose.
But any help would be appreciated.
regards,
-v-



--
View this message in context: http://camel.465427.n5.nabble.com/Forcefully-shutting-down-routes-tp5722447p5722557.html
Sent from the Camel - Users mailing list archive at Nabble.com.
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful.

Re: Forcefully shutting down routes...

Posted by vishal1981 <vi...@ericsson.com>.
Thanks for all your replies so far.
Allow me to explain you my use case a little more in detail...
As part of my route I am using the EJB endpoint. All that the EJB does is
that it calls a stored procedure. The stored procedure takes a long time to
execute (in the order of two to three hours). My routes are created and
destroyed via a UI. Most of the time the routes will remain un-change once
defined by the user. However there could be cases where the user wants to
change the route. In this case I currently stop the route, remove the route
and then re-create a route based on his new definition.

Now, because of the long stored proc and for the fact that EJB component is
not shutdownaware I keep seeing those messages - "Waiting as there are still
1 inflight and pending exchanges to complete, timeout in -49 seconds." till
the whole stored proc finishes.

In such cases I want to just stop the stored proc and the endpoint. My
database transactions will ensure my data integrity is not compromised. 

Whats more confusing is that the EJB component gets called as pat of a Time
thread shared by other routes. I dont want to interrupt the time thread
since other routes will stop as well.

Sorry for being verbose.
But any help would be appreciated.
regards,
-v-



--
View this message in context: http://camel.465427.n5.nabble.com/Forcefully-shutting-down-routes-tp5722447p5722557.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Forcefully shutting down routes...

Posted by Ra...@cognizant.com.
I haven't looked at source code but looks like you don't want a "graceful shutdown" but rather a "kill" of the route (which can get complicated with transactions).

-----Original Message-----
From: Vishal Changrani [mailto:vishal.changrani@ericsson.com]
Sent: Saturday, November 10, 2012 12:57 AM
To: users@camel.apache.org
Subject: Forcefully shutting down routes...

Hi,

I am trying to shutdown a route by calling route.
Camelcontext.stopRoute(routeId, 0, TimeUnit.SECONDS, false / true); //tried both true and false

However the route continues to persist sometimes and I get the following messages..

DEBUG - Route: Publisher_21 suspended and shutdown deferred, was consuming from: Endpoint[timer://TIMER_FOR_PUBLISHER?daemon=true&fixedRate=true&period=60000]
INFO - Waiting as there are still 1 inflight and pending exchanges to complete, timeout in 0 seconds.
INFO - Waiting as there are still 1 inflight and pending exchanges to complete, timeout in -1 seconds.
......

(On the route orignally I had set .shutdownRoute(default);)

I understand that the route may indeed be busy processing messages but I really know what I am doing and want to force it to stop.

I read a few posts related to this issue but am still a little lost. I am running Camel 2.9.2 and is there no way that the route's process can be just interrupted ?

Thanks,
V



This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful.

Re: Forcefully shutting down routes...

Posted by Christian Müller <ch...@gmail.com>.
The JavaDoc of a method is always a good source of information...
Why do you set the timeout to 0 seconds? It force Camel to interrupt the
shutdown immediately because it timed out. Try the stopRoute method without
a timeout (or at least only after a few seconds). On you shut down the
route from another thread. Otherwise there is at least one exchange in
flight...
And if you don't want a graceful shutdown (for whatever reason), provide
your own ShutdownStrategy [1].

[1] http://camel.apache.org/graceful-shutdown.html

Best,
Christian

On Fri, Nov 9, 2012 at 8:26 PM, Vishal Changrani <
vishal.changrani@ericsson.com> wrote:

> Hi,
>
> I am trying to shutdown a route by calling route.
> Camelcontext.stopRoute(routeId, 0, TimeUnit.SECONDS, false / true);
> //tried both true and false
>
> However the route continues to persist sometimes and I get the following
> messages..
>
> DEBUG - Route: Publisher_21 suspended and shutdown deferred, was consuming
> from:
> Endpoint[timer://TIMER_FOR_PUBLISHER?daemon=true&fixedRate=true&period=60000]
> INFO - Waiting as there are still 1 inflight and pending exchanges to
> complete, timeout in 0 seconds.
> INFO - Waiting as there are still 1 inflight and pending exchanges to
> complete, timeout in -1 seconds.
> ......
>
> (On the route orignally I had set .shutdownRoute(default);)
>
> I understand that the route may indeed be busy processing messages but I
> really know what I am doing and want to force it to stop.
>
> I read a few posts related to this issue but am still a little lost. I am
> running Camel 2.9.2 and is there no way that the route's process can be
> just interrupted ?
>
> Thanks,
> V
>
>
>
>


--