camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: ScheduledPollConsumer leaving threads around during removal
Date Fri, 20 Apr 2012 16:47:32 GMT
Hi

What version of Camel are you using?
This has been fixed in 2.9.2.


On Fri, Apr 20, 2012 at 6:42 PM, Jeff Segal <jeffrey.segal@gmail.com> wrote:
> I created a custom Component which extends ScheduledPollConsumer. I've
> found that when I stop and remove its Routes at runtime, the Routes are
> removed but two threads outlive the Route - one for
> the ScheduledExecutorService and one for the ShutdownTask. There are no
> in-flight Exchanges at the time I attempt to remove the Routes. The remove
> code looks like:
>
>            camelContext.stopRoute(routeId, 5000, TimeUnit.MILLISECONDS);
>            camelContext.removeRoute(routeId);
>
> Here is a snippet of the debug logs during a typical removal:
>
> 2012-04-20 12:15:31,082 4687910 [scheduler-2] INFO
>  org.apache.camel.impl.DefaultShutdownStrategy - Starting to graceful
> shutdown 1 routes (timeout 5000 milliseconds)
> 2012-04-20 12:15:31,089 4687917 [Camel (camel) thread #2 - ShutdownTask]
> DEBUG org.apache.camel.impl.DefaultShutdownStrategy - There are 1 routes to
> shutdown
> 2012-04-20 12:15:31,094 4687922 [Camel (camel) thread #2 - ShutdownTask]
> DEBUG org.apache.camel.impl.DefaultShutdownStrategy - Route:
> 4f689b87aa86b371be951fa3 suspended and shutdown deferred, was consuming
> from: Endpoint[ <MyCustomRouteHere> ]
> 2012-04-20 12:15:31,095 4687923 [Camel (camel) thread #2 - ShutdownTask]
> DEBUG org.apache.camel.impl.ScheduledPollConsumer - This consumer is
> stopping, so cancelling scheduled task:
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@63cc12b2
> 2012-04-20 12:15:31,100 4687928 [Camel (camel) thread #2 - ShutdownTask]
> DEBUG mil.disa.sw.server.camel.components.JumPollingConsumer - Stopping
> consumer: Consumer[ <MyCustomRouteHere> ]
> 2012-04-20 12:15:31,103 4687931 [Camel (camel) thread #2 - ShutdownTask]
> DEBUG org.apache.camel.impl.ProcessorEndpoint$1 - Stopping producer:
> Producer[bean://dataCacheManager?cache=true&method=onData]
> 2012-04-20 12:15:31,108 4687936 [Camel (camel) thread #2 - ShutdownTask]
> INFO  org.apache.camel.impl.DefaultShutdownStrategy - Route:
> 4f689b87aa86b371be951fa3 shutdown complete, was consuming from: Endpoint[
> <MyCustomRouteHere> ]
> 2012-04-20 12:15:31,109 4687937 [scheduler-2] INFO
>  org.apache.camel.impl.DefaultShutdownStrategy - Graceful shutdown of 1
> routes completed in 0 seconds
> 2012-04-20 12:15:31,243 4688071 [scheduler-2] INFO
>  org.apache.camel.spring.SpringCamelContext - Route:
> 4f689b87aa86b371be951fa3 shutdown and removed, was consuming from:
> Endpoint[ <MyCustomRouteHere> ]
>
> So it looks like a perfectly clean shutdown and removal occurred, yet when
> I look in jconsole I see the two threads hanging around perpetually.
> Subsequent runs of the removal test create new timer threads and re-use the
> existing ShutdownTask thread.
>
> Looking at the source for doStop() in ScheduledPollConsumer, I suspect that
> the call to future.cancel(false) may be returning false. Unfortunately I
> can't override that behavior since future has private access in
> ScheduledPollConsumer. The solution may be as simple as providing a
> configurable forceShutdown variable for ScheduledPollConsumer and/or
> bumping the future object to protected access. I'm happy to created a
> ticket in JIRA for this if it'd be useful.
>
> Thanks,
> Jeff



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
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/

Mime
View raw message