You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Gaurav Kumar <ku...@gmail.com> on 2023/01/10 07:38:23 UTC

Questions regarding Graceful shutdown

Hi Team
I am using camel version 3.14.4 and trying to implement clean shutdown. As
per the link below
https://camel.apache.org/manual/graceful-shutdown.html , I can implement
Graceful shutdown by implementing  DefaultShutdownStrategy.
I have added it in configuration and can see that bean has been created but
when I shutdown the VM then I can see in the logs that
SimpleMainShutdownStrategy  and DefaultMainShutdown Strategy is getting
called instead of  DefaultShutdownStrategy.

Can you please let me know what could be the issue or any alternative to
implement graceful shutdown. Basically I want to process all the in-flight
messages (in camel VM queues) before shutting down the VM.

-- 
Regards
Gaurav

Re: Questions regarding Graceful shutdown

Posted by Marco Carletti <ma...@gmail.com>.
hello,
you can try to set the shutdown properties in the context, trying different
combinations as described in the page you linked, for example:

context.setShutdownStrategy(new DefaultShutdownStrategy());
context.getShutdownStrategy().setTimeUnit(TimeUnit.MINUTES);
context.getShutdownStrategy().setTimeout(60);
context.setShutdownRoute(ShutdownRoute.Defer);
context.setShutdownRunningTask(ShutdownRunningTask.CompleteAllTasks);


hope this help

regards,
Marco

Il giorno mar 10 gen 2023 alle ore 08:38 Gaurav Kumar <
kumargaurav15@gmail.com> ha scritto:

> Hi Team
> I am using camel version 3.14.4 and trying to implement clean shutdown. As
> per the link below
> https://camel.apache.org/manual/graceful-shutdown.html , I can implement
> Graceful shutdown by implementing  DefaultShutdownStrategy.
> I have added it in configuration and can see that bean has been created but
> when I shutdown the VM then I can see in the logs that
> SimpleMainShutdownStrategy  and DefaultMainShutdown Strategy is getting
> called instead of  DefaultShutdownStrategy.
>
> Can you please let me know what could be the issue or any alternative to
> implement graceful shutdown. Basically I want to process all the in-flight
> messages (in camel VM queues) before shutting down the VM.
>
> --
> Regards
> Gaurav
>

Re: Questions regarding Graceful shutdown

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Okay so spring-main is using camel-main to run Camel standalone (not Spring
Boot etc) and therefore it comes with its own shutdown strategy
to ensure the entire JVM shutdown cleanly.

You cannot use <bean> to define a custom strategy in this situation.

You can configure the spring main instance where you have a
getShutdownStrategy() method where you can configure it from java code.



On Tue, Jan 10, 2023 at 2:58 PM Gaurav Kumar <ku...@gmail.com>
wrote:

> I am using camel-spring-main, i will try changing to camel-main and see if
> DefaultShudownStrategy comes into action.
>
> On Tue, 10 Jan 2023, 17:30 Claus Ibsen, <cl...@gmail.com> wrote:
>
> > How do you start and run Camel? Do you use camel-main / camel-spring-main
> > or some other way?
> > As it indicate that if you do then it comes with its own shutdown
> strategy.
> >
> >
> > On Tue, Jan 10, 2023 at 11:42 AM Gaurav Kumar <ku...@gmail.com>
> > wrote:
> >
> > > Thanks  for your response.
> > >
> > > I have tried setting up in context
> > > context.setShutdownStrategy(new DefaultShutdownStrategy());
> > > and it is not working.
> > >
> > > I have configured the strategy in configuration as below
> > >
> > > *<bean id="shutdown" class =
> > > "org.apace.camel.impl.engine.DefaultShutdownStrategy ">*
> > > *< property name ="timeout" value ="30"*
> > > *</bean>*
> > >
> > > I am running camel using spring but not Spring Boot.  Problem is I can
> > see
> > > the instance of  DefaultShutdownStrategy via JMX console but when I
> stop
> > > the application it is not getting called, instead I can see the below
> in
> > > logs.
> > >
> > >  *2022-12-05 02:43:49,424 DEBUG
> > > org.apache.camel.main.DefaultMainShutdownStrategy:75 - Received hangup
> > > signal, stopping the main instance.*
> > >
> > >
> > >
> > > On Tue, 10 Jan 2023 at 13:53, Claus Ibsen <cl...@gmail.com>
> wrote:
> > >
> > > > How do you run Camel? Spring Boot or some other way.
> > > >
> > > > Also you should 99% not implement your own shutdown strategy but just
> > > > configure the out of the box.
> > > >
> > > > On Tue, Jan 10, 2023 at 8:38 AM Gaurav Kumar <
> kumargaurav15@gmail.com>
> > > > wrote:
> > > >
> > > > > Hi Team
> > > > > I am using camel version 3.14.4 and trying to implement clean
> > shutdown.
> > > > As
> > > > > per the link below
> > > > > https://camel.apache.org/manual/graceful-shutdown.html , I can
> > > implement
> > > > > Graceful shutdown by implementing  DefaultShutdownStrategy.
> > > > > I have added it in configuration and can see that bean has been
> > created
> > > > but
> > > > > when I shutdown the VM then I can see in the logs that
> > > > > SimpleMainShutdownStrategy  and DefaultMainShutdown Strategy is
> > getting
> > > > > called instead of  DefaultShutdownStrategy.
> > > > >
> > > > > Can you please let me know what could be the issue or any
> alternative
> > > to
> > > > > implement graceful shutdown. Basically I want to process all the
> > > > in-flight
> > > > > messages (in camel VM queues) before shutting down the VM.
> > > > >
> > > > > --
> > > > > Regards
> > > > > Gaurav
> > > > >
> > > >
> > > >
> > > > --
> > > > Claus Ibsen
> > > > -----------------
> > > > @davsclaus
> > > > Camel in Action 2: https://www.manning.com/ibsen2
> > > >
> > >
> > >
> > > --
> > > Regards
> > > Gaurav
> > >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
> >
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Questions regarding Graceful shutdown

Posted by Gaurav Kumar <ku...@gmail.com>.
I am using camel-spring-main, i will try changing to camel-main and see if
DefaultShudownStrategy comes into action.

On Tue, 10 Jan 2023, 17:30 Claus Ibsen, <cl...@gmail.com> wrote:

> How do you start and run Camel? Do you use camel-main / camel-spring-main
> or some other way?
> As it indicate that if you do then it comes with its own shutdown strategy.
>
>
> On Tue, Jan 10, 2023 at 11:42 AM Gaurav Kumar <ku...@gmail.com>
> wrote:
>
> > Thanks  for your response.
> >
> > I have tried setting up in context
> > context.setShutdownStrategy(new DefaultShutdownStrategy());
> > and it is not working.
> >
> > I have configured the strategy in configuration as below
> >
> > *<bean id="shutdown" class =
> > "org.apace.camel.impl.engine.DefaultShutdownStrategy ">*
> > *< property name ="timeout" value ="30"*
> > *</bean>*
> >
> > I am running camel using spring but not Spring Boot.  Problem is I can
> see
> > the instance of  DefaultShutdownStrategy via JMX console but when I stop
> > the application it is not getting called, instead I can see the below in
> > logs.
> >
> >  *2022-12-05 02:43:49,424 DEBUG
> > org.apache.camel.main.DefaultMainShutdownStrategy:75 - Received hangup
> > signal, stopping the main instance.*
> >
> >
> >
> > On Tue, 10 Jan 2023 at 13:53, Claus Ibsen <cl...@gmail.com> wrote:
> >
> > > How do you run Camel? Spring Boot or some other way.
> > >
> > > Also you should 99% not implement your own shutdown strategy but just
> > > configure the out of the box.
> > >
> > > On Tue, Jan 10, 2023 at 8:38 AM Gaurav Kumar <ku...@gmail.com>
> > > wrote:
> > >
> > > > Hi Team
> > > > I am using camel version 3.14.4 and trying to implement clean
> shutdown.
> > > As
> > > > per the link below
> > > > https://camel.apache.org/manual/graceful-shutdown.html , I can
> > implement
> > > > Graceful shutdown by implementing  DefaultShutdownStrategy.
> > > > I have added it in configuration and can see that bean has been
> created
> > > but
> > > > when I shutdown the VM then I can see in the logs that
> > > > SimpleMainShutdownStrategy  and DefaultMainShutdown Strategy is
> getting
> > > > called instead of  DefaultShutdownStrategy.
> > > >
> > > > Can you please let me know what could be the issue or any alternative
> > to
> > > > implement graceful shutdown. Basically I want to process all the
> > > in-flight
> > > > messages (in camel VM queues) before shutting down the VM.
> > > >
> > > > --
> > > > Regards
> > > > Gaurav
> > > >
> > >
> > >
> > > --
> > > Claus Ibsen
> > > -----------------
> > > @davsclaus
> > > Camel in Action 2: https://www.manning.com/ibsen2
> > >
> >
> >
> > --
> > Regards
> > Gaurav
> >
>
>
> --
> Claus Ibsen
> -----------------
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>

Re: Questions regarding Graceful shutdown

Posted by Claus Ibsen <cl...@gmail.com>.
How do you start and run Camel? Do you use camel-main / camel-spring-main
or some other way?
As it indicate that if you do then it comes with its own shutdown strategy.


On Tue, Jan 10, 2023 at 11:42 AM Gaurav Kumar <ku...@gmail.com>
wrote:

> Thanks  for your response.
>
> I have tried setting up in context
> context.setShutdownStrategy(new DefaultShutdownStrategy());
> and it is not working.
>
> I have configured the strategy in configuration as below
>
> *<bean id="shutdown" class =
> "org.apace.camel.impl.engine.DefaultShutdownStrategy ">*
> *< property name ="timeout" value ="30"*
> *</bean>*
>
> I am running camel using spring but not Spring Boot.  Problem is I can see
> the instance of  DefaultShutdownStrategy via JMX console but when I stop
> the application it is not getting called, instead I can see the below in
> logs.
>
>  *2022-12-05 02:43:49,424 DEBUG
> org.apache.camel.main.DefaultMainShutdownStrategy:75 - Received hangup
> signal, stopping the main instance.*
>
>
>
> On Tue, 10 Jan 2023 at 13:53, Claus Ibsen <cl...@gmail.com> wrote:
>
> > How do you run Camel? Spring Boot or some other way.
> >
> > Also you should 99% not implement your own shutdown strategy but just
> > configure the out of the box.
> >
> > On Tue, Jan 10, 2023 at 8:38 AM Gaurav Kumar <ku...@gmail.com>
> > wrote:
> >
> > > Hi Team
> > > I am using camel version 3.14.4 and trying to implement clean shutdown.
> > As
> > > per the link below
> > > https://camel.apache.org/manual/graceful-shutdown.html , I can
> implement
> > > Graceful shutdown by implementing  DefaultShutdownStrategy.
> > > I have added it in configuration and can see that bean has been created
> > but
> > > when I shutdown the VM then I can see in the logs that
> > > SimpleMainShutdownStrategy  and DefaultMainShutdown Strategy is getting
> > > called instead of  DefaultShutdownStrategy.
> > >
> > > Can you please let me know what could be the issue or any alternative
> to
> > > implement graceful shutdown. Basically I want to process all the
> > in-flight
> > > messages (in camel VM queues) before shutting down the VM.
> > >
> > > --
> > > Regards
> > > Gaurav
> > >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
> >
>
>
> --
> Regards
> Gaurav
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Questions regarding Graceful shutdown

Posted by Gaurav Kumar <ku...@gmail.com>.
Thanks  for your response.

I have tried setting up in context
context.setShutdownStrategy(new DefaultShutdownStrategy());
and it is not working.

I have configured the strategy in configuration as below

*<bean id="shutdown" class =
"org.apace.camel.impl.engine.DefaultShutdownStrategy ">*
*< property name ="timeout" value ="30"*
*</bean>*

I am running camel using spring but not Spring Boot.  Problem is I can see
the instance of  DefaultShutdownStrategy via JMX console but when I stop
the application it is not getting called, instead I can see the below in
logs.

 *2022-12-05 02:43:49,424 DEBUG
org.apache.camel.main.DefaultMainShutdownStrategy:75 - Received hangup
signal, stopping the main instance.*



On Tue, 10 Jan 2023 at 13:53, Claus Ibsen <cl...@gmail.com> wrote:

> How do you run Camel? Spring Boot or some other way.
>
> Also you should 99% not implement your own shutdown strategy but just
> configure the out of the box.
>
> On Tue, Jan 10, 2023 at 8:38 AM Gaurav Kumar <ku...@gmail.com>
> wrote:
>
> > Hi Team
> > I am using camel version 3.14.4 and trying to implement clean shutdown.
> As
> > per the link below
> > https://camel.apache.org/manual/graceful-shutdown.html , I can implement
> > Graceful shutdown by implementing  DefaultShutdownStrategy.
> > I have added it in configuration and can see that bean has been created
> but
> > when I shutdown the VM then I can see in the logs that
> > SimpleMainShutdownStrategy  and DefaultMainShutdown Strategy is getting
> > called instead of  DefaultShutdownStrategy.
> >
> > Can you please let me know what could be the issue or any alternative to
> > implement graceful shutdown. Basically I want to process all the
> in-flight
> > messages (in camel VM queues) before shutting down the VM.
> >
> > --
> > Regards
> > Gaurav
> >
>
>
> --
> Claus Ibsen
> -----------------
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>


-- 
Regards
Gaurav

Re: Questions regarding Graceful shutdown

Posted by Claus Ibsen <cl...@gmail.com>.
How do you run Camel? Spring Boot or some other way.

Also you should 99% not implement your own shutdown strategy but just
configure the out of the box.

On Tue, Jan 10, 2023 at 8:38 AM Gaurav Kumar <ku...@gmail.com>
wrote:

> Hi Team
> I am using camel version 3.14.4 and trying to implement clean shutdown. As
> per the link below
> https://camel.apache.org/manual/graceful-shutdown.html , I can implement
> Graceful shutdown by implementing  DefaultShutdownStrategy.
> I have added it in configuration and can see that bean has been created but
> when I shutdown the VM then I can see in the logs that
> SimpleMainShutdownStrategy  and DefaultMainShutdown Strategy is getting
> called instead of  DefaultShutdownStrategy.
>
> Can you please let me know what could be the issue or any alternative to
> implement graceful shutdown. Basically I want to process all the in-flight
> messages (in camel VM queues) before shutting down the VM.
>
> --
> Regards
> Gaurav
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2