activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim_Stringer <>
Subject Problems with Rollbacks
Date Thu, 15 Mar 2007 14:20:19 GMT

I've been trying to figure this out for the last few day and I've run out of
ideas. I am testing a message driven been ActiveMQ 4.1 using Jencks 2.0 and
Spring 2.0.3. Things work fine when no runtime exception is thrown in my
message listener. When I do through one ActiveMQ reconnects to the broker
and neither the rolled back message nor any other message  makes it to my
listener until I restart the application.

This is my Spring file for the listener.

<?xml version="1.0" encoding="UTF-8"?>

<!-- START SNIPPET: spring -->
  || The TransactionManager
  <bean id="transactionManager"

  <!-- START SNIPPET: jca -->
  <bean id="jencks" class="org.jencks.JCAContainer">
    <property name="transactionManager" ref="transactionManager"/>
    <property name="threadPoolSize" value="25"/>

    <!-- the JCA Resource Adapter -->
    <property name="resourceAdapter">
      <bean id="activeMQResourceAdapter"
        <property name="serverUrl" value="tcp://localhost:61616"/>
  <!-- END SNIPPET: jca -->

  <bean id="echoBean" class="my.sandbox.jms.EchoBean"/>
  <!-- END SNIPPET: inbound -->

    || an inbound message connector using a stateful, pooled 
  <bean id="requestResponseMEP" class="org.jencks.JCAConnector">

        <property name="jcaContainer" ref="jencks" />

    <!-- subscription details -->
    <property name="activationSpec">
      <bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
        <property name="destination" value="test.spring.inboundConnectorB"/>
        <property name="destinationType" value="javax.jms.Queue"/>

    <!-- use XA transactions -->
    <property name="transactionManager" ref="transactionManager"/>

    <property name="ref" value="echoBean"/>

        <!-- END SNIPPET: spring -->

The EchoBean is very simple.

package my.sandbox.jms;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class EchoBean implements MessageListener
        private final Log logger = LogFactory.getLog(getClass());
        public void onMessage(Message message)
                try {
              "onMessage: " +
                        throw new RuntimeException("Boom!...Please roll me
                } catch (JMSException e) {


Stepping through the code it appears that the exception makes it all the way
back to ActiveMQSession and hits this snippet...

            try {
            } catch ( Throwable e ) {  
                // TODO: figure out proper way to handle error.
                log.error("error dispatching message: ",e);

That TODO ends up closing the current connections to the broker and while it
does reconnect the messages never get to the listener. They get as far as
the ActiveMQSession  but a flag appears to not let them be processed. I have
gotten the rollback to work using Springs DefaultMessageListenerContainer
but I'm not a big fan of it for an enterprise solution.

I know something very obvious is staring me right in the face, but after 3
days I'm hoping somebody will tell me what it is. I'd appreciate any help.
View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message