You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by David Durham <da...@gmail.com> on 2009/06/22 21:40:44 UTC

inactivity monitor hangs tomcat shutdown

Hi all,

I've got a simple ActiveMQ client running inside Tomcat.  When I
shutdown Tomcat I get an exception from the "Inactivity Monitor Write
Check" thread.  My question is has anyone seen this issue and have a
fix for it?  I've tried making sure that I call the stop() method on
my CamelContext, but I don't see how I would call stop on the
Inactivity Monitor Read and Write threads.

Thanks,
Dave

Re: inactivity monitor hangs tomcat shutdown

Posted by David Durham <da...@gmail.com>.
http://issues.apache.org/activemq/browse/CAMEL-1751

Re: inactivity monitor hangs tomcat shutdown

Posted by David Durham <da...@gmail.com>.
Disregard this section.  It was a double paste ..

>    <bean id="returnQueues"
> class="com.inwk.jobtemplate.server.ReturnedQueueRouteBuilder"
> lazy-init="false" init-method="init" destroy-method="stop">
>        <property name="routes">
>            <map>
>                <entry key="${customerportal.quote.returnQueue.name}">
>                    <bean
> class="com.inwk.jobtemplate.server.ReturnedQuotesProcessor">
>                        <property name="quoteRequestDao"
> ref="quoteRequestDao" />
>                    </bean>
>                </entry>
>                <entry key="${customerportal.order.returnQueue.name}">
>                    <bean
> class="com.inwk.jobtemplate.server.ReturnedOrdersProcessor">
>                        <property name="orderDao" ref="orderDao" />
>                    </bean>
>                </entry>
>            </map>
>        </property>
>        <property name="camelContext" ref="camelContext" />
>        <property name="activeMQName"
> value="${core.quote.queue.activeMQInstance}" />
>        <property name="remoteAddress"
> value="${core.quote.queue.remoteAddress}" />
>    </bean>

Re: inactivity monitor hangs tomcat shutdown

Posted by David Durham <da...@gmail.com>.
On Tue, Jun 23, 2009 at 8:34 AM, David Durham<da...@gmail.com> wrote:
> On Tue, Jun 23, 2009 at 4:35 AM, Gary Tully<ga...@gmail.com> wrote:
>> I wonder if this is the result of code registered with a shutdown hook and
>> at shutdown some of the required classes are not longer available.
>> One way to check is to have the broker not register any shutdown hook.
>>
>> Set the 'useShutdownHook' property to false for the ActiveMQ broker in your
>> xml configuration.
>
> I'm actually not running a broker (that I know of).
>
> I'll post my exact configuration when I can, but my setup is that I'm
> only running a client.  I have a couple Processors set up that check 2
> "inbound" queues and I post objects to 2 other "outbound" queues.

Here's my spring config.  I have the following for 'inbound' return queues.

    <bean id="returnQueues" class="com.ReturnedQueueRouteBuilder"
lazy-init="false" init-method="init" destroy-method="stop">
        <property name="routes">
            <map>
                <entry key="${a.returnQueue.name}">
                    <bean class="com.ReturnedAProcessor">
                        <property name="x" ref="y" />
                    </bean>
                </entry>
                <entry key="${b.returnQueue.name}">
                    <bean class="com.ReturnedBProcessor">
                        <property name="x" ref="y />
                    </bean>
                </entry>
            </map>
        </property>
        <property name="camelContext" ref="camelContext" />
        <property name="activeMQName" value="${queue.activeMQInstance}" />
        <property name="remoteAddress" value="${queue.remoteAddress}" />
    </bean>

    <bean id="camelContext" class="org.apache.camel.impl.DefaultCamelContext" />

Init method for ReturnQueueRouteBuilder init method looks like:

    public void init() {
        camelContext.addComponent(activeMQName.trim(),
ActiveMQComponent.activeMQComponent(remoteAddress.trim()));
        try {
            camelContext.addRoutes(this);
            camelContext.start();
        } catch (Exception e) {
            log.error(e);
        }
    }

and configure:

    public void configure() throws Exception {
        for (Map.Entry<String, Processor> route : routes.entrySet()) {
            from(route.getKey()).process(route.getValue());
        }
    }



For outbound, I have this:

    <bean id="newObjectQueue" class="com.NewObjectQueueImpl">
        <property name="camelContext" ref="camelContext" />
        <property name="queues">
            <map>
                <entry key="com.SomeObject" value="${queue.a.name}" />
                <entry key="com.SomeOtherObject" value="${queue.b.name}" />
            </map>
        </property>
    </bean>

This just maps class names to a queue name.  So in the new object queue:

        ProducerTemplate template = camelContext.createProducerTemplate();
        template.sendBody(queues.get(newObject.getClass().getName()),
objectString);


    <bean id="returnQueues"
class="com.inwk.jobtemplate.server.ReturnedQueueRouteBuilder"
lazy-init="false" init-method="init" destroy-method="stop">
        <property name="routes">
            <map>
                <entry key="${customerportal.quote.returnQueue.name}">
                    <bean
class="com.inwk.jobtemplate.server.ReturnedQuotesProcessor">
                        <property name="quoteRequestDao"
ref="quoteRequestDao" />
                    </bean>
                </entry>
                <entry key="${customerportal.order.returnQueue.name}">
                    <bean
class="com.inwk.jobtemplate.server.ReturnedOrdersProcessor">
                        <property name="orderDao" ref="orderDao" />
                    </bean>
                </entry>
            </map>
        </property>
        <property name="camelContext" ref="camelContext" />
        <property name="activeMQName"
value="${core.quote.queue.activeMQInstance}" />
        <property name="remoteAddress"
value="${core.quote.queue.remoteAddress}" />
    </bean>

Keep in mind that for right now, I am not concerned with performance,
though suggestions are of course welcome.  RIght now, I'm trying to
get this setup to work gracefully with Tomcat, i.e., Tomcat should not
hang on shutdown.  The hang is I think caused by active non-daemon
threads spawned from camelContext.start(), but I also see the
following stack trace:

   1.
      Exception in thread "InactivityMonitor WriteCheck"
java.lang.NoClassDefFoundError:
org/apache/activemq/transport/InactivityMonitor$3
              at
org.apache.activemq.transport.InactivityMonitor.writeCheck(InactivityMonitor.java:128)
              at
org.apache.activemq.transport.InactivityMonitor$2.run(InactivityMonitor.java:103)
              at
org.apache.activemq.thread.SchedulerTimerTask.run(SchedulerTimerTask.java:33)
              at java.util.TimerThread.mainLoop(Timer.java:512)
              at java.util.TimerThread.run(Timer.java:462)
      Caused by: java.lang.ClassNotFoundException:
org.apache.activemq.transport.InactivityMonitor$3
              at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
              at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
              ... 5 more

Thanks,
Dave

Re: inactivity monitor hangs tomcat shutdown

Posted by David Durham <da...@gmail.com>.
On Tue, Jun 23, 2009 at 4:35 AM, Gary Tully<ga...@gmail.com> wrote:
> I wonder if this is the result of code registered with a shutdown hook and
> at shutdown some of the required classes are not longer available.
> One way to check is to have the broker not register any shutdown hook.
>
> Set the 'useShutdownHook' property to false for the ActiveMQ broker in your
> xml configuration.

I'm actually not running a broker (that I know of).

I'll post my exact configuration when I can, but my setup is that I'm
only running a client.  I have a couple Processors set up that check 2
"inbound" queues and I post objects to 2 other "outbound" queues.

Thanks,
Dave

Re: inactivity monitor hangs tomcat shutdown

Posted by Gary Tully <ga...@gmail.com>.
I wonder if this is the result of code registered with a shutdown hook and
at shutdown some of the required classes are not longer available.
One way to check is to have the broker not register any shutdown hook.

Set the 'useShutdownHook' property to false for the ActiveMQ broker in your
xml configuration.

2009/6/22 David Durham <da...@gmail.com>

> >> I've got a simple ActiveMQ client running inside Tomcat.  When I
> >> shutdown Tomcat I get an exception from the "Inactivity Monitor Write
> >> Check" thread.  My question is has anyone seen this issue and have a
> >> fix for it?  I've tried making sure that I call the stop() method on
> >> my CamelContext, but I don't see how I would call stop on the
> >> Inactivity Monitor Read and Write threads.
> >
> > Here's a stack trace:
> >
> > http://pastebin.ca/1470211
>
> Actually, maybe this isn't the cause of the hang.  It's an assumption
> on my part, because I see this error message and the server hangs.
> Now I'm thinking that the Tomcat hangage could be caused by the fact
> that there are still non-daemon threads running.  There's a couple of
> Active MQ transport threads and a couple of
> DefaultMessageListenerContainer running.  Anyone have experience with
> using ActiveMQ/Camel and Spring under Tomcat?  I'd really prefer to
> not have to 'kill -9' tomcat.
>
> Thanks,
> Dave
>



-- 
http://blog.garytully.com

Open Source Integration
http://fusesource.com

Re: inactivity monitor hangs tomcat shutdown

Posted by David Durham <da...@gmail.com>.
>> I've got a simple ActiveMQ client running inside Tomcat.  When I
>> shutdown Tomcat I get an exception from the "Inactivity Monitor Write
>> Check" thread.  My question is has anyone seen this issue and have a
>> fix for it?  I've tried making sure that I call the stop() method on
>> my CamelContext, but I don't see how I would call stop on the
>> Inactivity Monitor Read and Write threads.
>
> Here's a stack trace:
>
> http://pastebin.ca/1470211

Actually, maybe this isn't the cause of the hang.  It's an assumption
on my part, because I see this error message and the server hangs.
Now I'm thinking that the Tomcat hangage could be caused by the fact
that there are still non-daemon threads running.  There's a couple of
Active MQ transport threads and a couple of
DefaultMessageListenerContainer running.  Anyone have experience with
using ActiveMQ/Camel and Spring under Tomcat?  I'd really prefer to
not have to 'kill -9' tomcat.

Thanks,
Dave

Re: inactivity monitor hangs tomcat shutdown

Posted by David Durham <da...@gmail.com>.
On Mon, Jun 22, 2009 at 2:40 PM, David Durham<da...@gmail.com> wrote:
> Hi all,
>
> I've got a simple ActiveMQ client running inside Tomcat.  When I
> shutdown Tomcat I get an exception from the "Inactivity Monitor Write
> Check" thread.  My question is has anyone seen this issue and have a
> fix for it?  I've tried making sure that I call the stop() method on
> my CamelContext, but I don't see how I would call stop on the
> Inactivity Monitor Read and Write threads.

Here's a stack trace:

http://pastebin.ca/1470211