activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Durham <david.durham...@gmail.com>
Subject Re: inactivity monitor hangs tomcat shutdown
Date Tue, 23 Jun 2009 14:57:52 GMT
On Tue, Jun 23, 2009 at 8:34 AM, David Durham<david.durham.jr@gmail.com> wrote:
> On Tue, Jun 23, 2009 at 4:35 AM, Gary Tully<gary.tully@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

Mime
View raw message