Thanks Claus.

I'm on v2.25.1 (TomEE + CDI) and didn't found any examples/docs about how to 
set the SupervisingRouteController, so here is what I did:

    @Produces
    @ApplicationScoped
    CamelContext customize() {
        SupervisingRouteController controller = new 
SupervisingRouteController();
        BackOff backOff = new BackOff();
        backOff.setDelay(Duration.ofMillis(3000));
        backOff.setMaxDelay(Duration.ofMillis(30000));
        backOff.setMultiplier(2.0);
        controller.setBackOff("jms-events", backOff);
        
        context = new DefaultCamelContext();
        controller.setCamelContext(context);
        context.setRouteController(controller);        
       ... the rest of the context initialization

The first exception (when subscription is already taken)  is logged initially 
and I can see this right after it:

2020-08-20 14:20:49.732 [http-nio-8081-exec-4] INFO  
o.a.c.i.SupervisingRouteController$RouteManager - Start supervising route: 
jms-events with back-off: BackOff{delay=PT3S, maxDelay=PT30S, 
maxElapsedTime=PT2562047788015H12M55.807S, maxAttempts=100, multiplier=2.0}
2020-08-20 14:20:49.737 [http-nio-8081-exec-4] INFO  
o.a.c.i.SupervisingRouteController - Total managed routes: 7 of which 6 
successfully started and 1 re-starting

Then, after 6 seconds:

2020-08-20 14:20:55.736 [Camel Thread #1 - Supervi] INFO  
o.a.c.i.SupervisingRouteController$RouteManager - Try to restart route: 
jms-events
2020-08-20 14:20:55.913 [Camel Thread #1 - Supervi] ERROR 
o.a.c.component.sjms.SjmsConsumer - Unable to create the MessageConsumer
javax.jms.IllegalStateException: Cannot create a subscriber on the durable 
subscription since it already has subscriber(s)
        at 
org.apache.activemq.artemis.jms.client.ActiveMQSession.createConsumer(ActiveMQSession.java:865)

And then after another 12 sec:

2020-08-20 14:21:07.915 [Camel Thread #1 - Supervi] INFO  
o.a.c.i.SupervisingRouteController$RouteManager - Try to restart route: 
jms-events
2020-08-20 14:21:07.915 [Camel Thread #1 - Supervi] INFO  
o.a.camel.impl.DefaultCamelContext - Route: jms-events started and consuming 
from: sjms://topic:kt.mix.easybook.events?durableSubscriptionId=tire-lodge-dev

But, It is not actually consuming anything - confirmed (subscription is still 
taken). Is it a bug or I'm missing something?

Cheers,
Dmitry

-----Original Message-----
From: Claus Ibsen [mailto:claus.ib...@gmail.com] 
Sent: Wednesday, August 19, 2020 10:03 PM
To: users@camel.apache.org
Subject: Re: SJMS2 durable subscription lazy re-connect

Hi

In Camel 3 there is a route controller you can use to configure Camel to 
restart the failing route up till X times.
In Camel 2 that controller was implemented as an experiment so you may find it 
there and try to use it for 2.25.x

On Wed, Aug 19, 2020 at 10:08 PM Shultz, Dmitry <dmitry_shu...@kaltire.com> 
wrote:
>
> Hi All,
>
> I'm migrating the service from camel-jms to came-sjms2 component (connecting 
> to Artemis brokers) and it all good except of one change in behaviour which 
> breaks the Kubernetes redeployment.
>
> When service app (helm) is redeployed using Ranched UI it brings the new 
> service pod up, checks if it's up (readiness check) and shuts down the old 
> one. When using the camel-jms the new service complained about not being able 
> to create the durable subscription (because it is already taken by the 
> running pod) but it didn't fail the deployment, so readiness check passes, 
> old service is killed by the K8's and new service successfully reconnects 
> later.
> Now, when sjms2 is used, the whole deployment (tomee) fails when durable 
> subscription is not available, so readiness check never passes.
>
> Is there any way to make it behave like the old camel-jms, so the context is 
> not shutdown when subscription is not available?
>
> 2020-08-19 13:03:10.773 [localhost-startStop-1] ERROR 
> o.a.c.component.sjms.SjmsConsumer - Unable to create the 
> MessageConsumer
> javax.jms.IllegalStateException: Cannot create a subscriber on the 
> durable subscription since it already has subscriber(s) at 
> org.apache.activemq.artemis.jms.client.ActiveMQSession.createConsumer(
> ActiveMQSession.java:865) at 
> org.apache.activemq.artemis.jms.client.ActiveMQSession.createDurableSu
> bscriber(ActiveMQSession.java:583)
> at 
> org.apache.activemq.artemis.jms.client.ActiveMQSession.createDurableSu
> bscriber(ActiveMQSession.java:557)
> at 
> org.apache.camel.component.sjms2.jms.Jms2ObjectFactory.createSubscript
> ionTopicConsumer(Jms2ObjectFactory.java:141)
> at 
> org.apache.camel.component.sjms2.jms.Jms2ObjectFactory.createTopicMess
> ageConsumer(Jms2ObjectFactory.java:97)
> at 
> org.apache.camel.component.sjms2.jms.Jms2ObjectFactory.createMessageCo
> nsumer(Jms2ObjectFactory.java:72) at 
> org.apache.camel.component.sjms2.jms.Jms2ObjectFactory.createMessageCo
> nsumer(Jms2ObjectFactory.java:56) at 
> org.apache.camel.component.sjms2.jms.Jms2ObjectFactory.createMessageCo
> nsumer(Jms2ObjectFactory.java:42) at 
> org.apache.camel.component.sjms.SjmsConsumer.createConsumer(SjmsConsum
> er.java:186) at 
> org.apache.camel.component.sjms.SjmsConsumer.access$000(SjmsConsumer.j
> ava:47) at 
> org.apache.camel.component.sjms.SjmsConsumer$MessageConsumerResourcesF
> actory.makeObject(SjmsConsumer.java:65)
> at 
> org.apache.camel.component.sjms.SjmsConsumer$MessageConsumerResourcesF
> actory.makeObject(SjmsConsumer.java:56)
> at 
> org.apache.commons.pool.impl.GenericObjectPool.addObject(GenericObject
> Pool.java:1691) at 
> org.apache.camel.component.sjms.SjmsConsumer.fillConsumersPool(SjmsCon
> sumer.java:138) at 
> org.apache.camel.component.sjms.SjmsConsumer.doStart(SjmsConsumer.java
> :131) at 
> org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:72)
> at 
> org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelCon
> text.java:3710) at 
> org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumer
> s(DefaultCamelContext.java:4028) at 
> org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(Defaul
> tCamelContext.java:3963) at 
> org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(Def
> aultCamelContext.java:3883) at 
> org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(Defaul
> tCamelContext.java:3647) at 
> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelCon
> text.java:3488) at 
> org.apache.camel.impl.DefaultCamelContext$4.call(DefaultCamelContext.j
> ava:3247) at 
> org.apache.camel.impl.DefaultCamelContext$4.call(DefaultCamelContext.j
> ava:3243) at 
> org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(Def
> aultCamelContext.java:3266) at 
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.
> java:3243) at 
> org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:72)
> at 
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.ja
> va:3159) at 
> org.apache.camel.CamelContext$$OwbNormalScopeProxy0.start(org/apache/c
> amel/CamelContext.java) at 
> org.apache.camel.cdi.CdiCamelExtension.afterDeploymentValidation(CdiCa
> melExtension.java:436) at 
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> ava:62) at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498)
> at 
> org.apache.webbeans.event.ObserverMethodImpl.invoke(ObserverMethodImpl
> .java:348) at 
> org.apache.webbeans.event.ContainerEventObserverMethodImpl.invoke(Cont
> ainerEventObserverMethodImpl.java:84)
> at 
> org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl
> .java:313) at 
> org.apache.webbeans.event.NotificationManager.fireEvent(NotificationMa
> nager.java:676) at 
> org.apache.webbeans.container.BeanManagerImpl.fireEvent(BeanManagerImp
> l.java:490) at 
> org.apache.webbeans.container.BeanManagerImpl.fireLifecycleEvent(BeanM
> anagerImpl.java:485) at 
> org.apache.webbeans.config.BeansDeployer.fireAfterDeploymentValidation
> Event(BeansDeployer.java:736) at 
> org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:330
> ) at 
> org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecy
> cle.java:196) at 
> org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSin
> gletonServiceImpl.java:189) at 
> org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:41)
> at 
> org.apache.openejb.assembler.classic.Assembler.createApplication(Assem
> bler.java:960) at 
> org.apache.openejb.assembler.classic.Assembler.createApplication(Assem
> bler.java:754) at 
> org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebA
> ppBuilder.java:1303) at 
> org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWeb
> AppBuilder.java:1125) at 
> org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalL
> istenerSupport.java:133) at 
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBas
> e.java:94) at 
> org.apache.catalina.core.StandardContext.startInternal(StandardContext
> .java:5134) at 
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
> at 
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.
> java:754) at 
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730
> ) at 
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:744)
> at 
> org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java
> :1135) at 
> org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.
> java:1869) at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511
> ) at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.j
> ava:1149) at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.
> java:624) at java.lang.Thread.run(Thread.java:748)
> 2020-08-19 13:03:10.775 [localhost-startStop-1] INFO 
> o.a.camel.impl.DefaultCamelContext - Apache Camel 2.25.1 
> (CamelContext: tire-lodge) is shutting down
>
> Cheers,
> Dmitry
>


--
Claus Ibsen
-----------------
https://urldefense.com/v3/__http://davsclaus.com__;!!LdWlNaMnLCM!MFMROMWFk7vw1WzlDsxG-l-HKIjSF69EKCqZUKMtF7TiuIEkD3bT1ZR-0HMOXnDFm3jI$
  @davsclaus Camel in Action 2: 
https://urldefense.com/v3/__https://www.manning.com/ibsen2__;!!LdWlNaMnLCM!MFMROMWFk7vw1WzlDsxG-l-HKIjSF69EKCqZUKMtF7TiuIEkD3bT1ZR-0HMOXlge_t6l$
 

Reply via email to