camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdo <manfred.doh...@gmail.com>
Subject 2.11, File2, Quartz: threads leaking
Date Thu, 02 May 2013 16:20:22 GMT
Hello,

I've constructed a thread leak somehow. I found some discussions/issues
describing past thread leaking problems, e.g.:
http://stackoverflow.com/q/10071814
http://stackoverflow.com/q/14992793
https://issues.apache.org/jira/browse/CAMEL-5072
http://camel.465427.n5.nabble.com/FTP-ConsumerTemplate-Threads-remaining-alive-td5548338.html

So obviously there has been some work to fix those issues. In one case Claus
advised the user that he must stop a producer template. I'm not sure how to
solve my problem. Find my setup description of a Quartz-triggered file
consumer route below.

A file consumer:
from("file:///tmp/x/?sendEmptyMessageWhenIdle=true") 
.noAutoStartup()
.routeId(routeId)
.choice()
    .when(body().isNull())
...

The null-Body is used as route-stop-trigger, I use a processor that starts
up a thread as described here:
http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html
... with these actions:
exchange.getContext().getInflightRepository().remove(exchange);
exchange.getContext().stopRoute(exchange.getFromRouteId());
I also tried a stop() on the getFromEndpoint() here.


A Quartz route, periodically firing the file consumer route based on cron
definitions:
from("quartz://timer-"+routeId+"?stateful=true&cron=...")
    .routeId("quartz-"+routeId)
    .process(new RouteStartProcessor(routeId));

process() in RouteStartProcessor:
CamelContext context = exchange.getContext();
context.startRoute(routeId);

I now added a loop to the RouteStartProcessor waiting for the file consumer
route to shutdown itself (to prevent overlaps), evaluated by:
routeStopped = context.getRouteStatus(routeId).isStopped();

This actually does work fine, so I assume that the route gets stopped
successfully. Logs: o.a.c.impl.DefaultShutdownStrategy - Graceful shutdown
of 1 routes completed in 0 seconds

Whenever Quartz fires and the consumer route gets re-started this brings up
a new thread id which I can see in the logs.

Albeit the route obviously is shut down, the threads stay alive, all in
state: java.lang.Thread.State: WAITING (parking)

I dug around a bit in the VM's MBeans, there are:
* 2 consumers, a FileConsumer and a QuartzConsumer
* a large amount of threadpools (equal to the number of waiting threads),
having IDs like FileConsumer(0x138dc688)

Attributes of an example instance:
Thread pool profile: --
Shutdown: false
Active count: 0
Pool size: 1
Task queue size: 0
Route: 
Keep alive time: 0
Source:
Completed task count: 2 
Core pool size: 1
Largest pool size: 1
Task count: 2
Id: FileConsumer(0x138dc688)
Maximum pool size: 2147483647
Task count: 2


My environment:
Linux
JDK 7
GlassFish 3
CDI Camel context
Camel 2.11.0


Any hints? Thanks in advance!

Regards, mdo.





--
View this message in context: http://camel.465427.n5.nabble.com/2-11-File2-Quartz-threads-leaking-tp5731922.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message