You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2012/07/11 18:39:12 UTC

Re: Exact behaviour of Camel Context stop method

On Wed, Jul 11, 2012 at 3:28 PM, anand_tech <an...@gmail.com> wrote:
> Hi ,
>
> I am making a simple application based on camel. It reads some files in a
> directory and then after processing  new files are made. The problem is that
> after files are made i call the stop method of camel context. But the code
> get stuck there, nothing happens further. This is very unexpected because
> later i will have to convert this code into a Swing GUI type application and
> then i want to give a restart or reload sort of functionality. but if camel
> context won't stop then it wouldn't be possible. so my exact question is
> what the exact behavior of stop method of camel context, because in my case
> it is obviously not working or lets say taking forever .
>

The stop() method will shutdown Camel in a graceful manner.
So it may take some time to do that.

You can read more here
http://camel.apache.org/graceful-shutdown.html

And a bit here as well
http://camel.apache.org/configuring-route-startup-ordering-and-autostartup.html

So if your stop() takes a long time, then there is most likely pending
inflight messages still in processing.




> Thanks
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Exact-behaviour-of-Camel-Context-stop-method-tp5715858.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.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Exact behaviour of Camel Context stop method

Posted by Pontus Ullgren <ul...@gmail.com>.
Hello,

If you call stop() directly from the route the current message (the
one being processed) is still inflight.

One way to solve it is to start a new thread and and call stop() from
there as is described here
http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html

Best regards
Pontus Ullgren

On Wed, Jul 11, 2012 at 9:10 PM, anand_tech <an...@gmail.com> wrote:
> If this is the case then when all files have been processed then possibly
> what can still exist in the inflight exchange, or is it that when it polls
> no file it will keep on returning null(since i have enabled
> sendemptyMessageIdle option)  after some delay(specified by delay). So is
> there any method or option for file consumer, that when it polls no file, it
> should shutdown. Or what if i explicitly tell the route that if no file is
> polled, return null to the bean and from there i shutdown the route myself.
> is this any good ?
>
> Also sometimes i get an error that "direct:InputFile" cannot create a second
> consumer error. This happens when i don't stop Camel Context and try to make
> another producer template for the endpoint.
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Exact-behaviour-of-Camel-Context-stop-method-tp5715858p5715880.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Exact behaviour of Camel Context stop method

Posted by anand_tech <an...@gmail.com>.
If this is the case then when all files have been processed then possibly
what can still exist in the inflight exchange, or is it that when it polls
no file it will keep on returning null(since i have enabled
sendemptyMessageIdle option)  after some delay(specified by delay). So is
there any method or option for file consumer, that when it polls no file, it
should shutdown. Or what if i explicitly tell the route that if no file is
polled, return null to the bean and from there i shutdown the route myself.
is this any good ?

Also sometimes i get an error that "direct:InputFile" cannot create a second
consumer error. This happens when i don't stop Camel Context and try to make
another producer template for the endpoint.


--
View this message in context: http://camel.465427.n5.nabble.com/Exact-behaviour-of-Camel-Context-stop-method-tp5715858p5715880.html
Sent from the Camel - Users mailing list archive at Nabble.com.