You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Harald Wellmann <hw...@googlemail.com> on 2012/04/13 14:41:00 UTC

Memory leak with ActiveMQComponent and PooledConnectionFactory

After configuring an ActiveMQComponent with a PooledConnectionFactory
as documented in
http://camel.apache.org/activemq.html,

I got a bunch of errror messages from Tomcat on servlet context shutdown:

13.04.2012 14:21:50 org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SCHWERWIEGEND: The web application [/tcm-web] appears to have started
a thread named [ActiveMQConnection[ID:tehh2d002-39063-1334319701701-0:1]
Scheduler] but has failed to stop it. This is very likely to create a
memory leak.
13.04.2012 14:21:50 org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SCHWERWIEGEND: The web application [/tcm-web] appears to have started
a thread named [ActiveMQ Transport: tcp://localhost/127.0.0.1:61616]
but has failed to stop it. This is very likely to create a memory
leak.
13.04.2012 14:21:50 org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SCHWERWIEGEND: The web application [/tcm-web] appears to have started
a thread named [InactivityMonitor ReadCheck] but has failed to stop
it. This is very likely to create a memory leak.
13.04.2012 14:21:50 org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SCHWERWIEGEND: The web application [/tcm-web] appears to have started
a thread named [InactivityMonitor WriteCheck] but has failed to stop
it. This is very likely to create a memory leak.
13.04.2012 14:21:50 org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SCHWERWIEGEND: The web application [/tcm-web] appears to have started
a thread named [ActiveMQ Session Task-1] but has failed to stop it.
This is very likely to create a memory leak.
13.04.2012 14:21:50 org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap

It seems the PooledConnectionFactory does not get stopped properly
when configured as documented. On the other hand, ActiveMQComponent
seems to create a pooled connection factory by default when simply
configured with the broker URL. ActiveMQ itself has another thread
pool which does not shutdown automatically. With the following Spring
configuration, I got rid of the memory leak messages:

@Configuration
public class CamelSpringConfig {

    @PreDestroy
    public void onShutdown() {
        DefaultThreadPools.shutdown();
    }

    @Bean
    public ActiveMQComponent activemq() {
        ActiveMQComponent component = new ActiveMQComponent();
        component.setBrokerURL("tcp://localhost:61616");
        return component;
    }
}

Would be great if someone could check this and update the Camel docs, if needed.

Best regads,
Harald