camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Segal <>
Subject ScheduledPollConsumer leaving threads around during removal
Date Fri, 20 Apr 2012 16:42:46 GMT
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);

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
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:
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:
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.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message