5 Replies Latest reply on Jul 5, 2012 12:30 PM by Justin Bertram

    JBoss 5.1 with Websphere MQ Resource Adapter: Infinite redeliveries

    John Smith Newbie

      Hello,

       

      I'm currently having a problem where messages are redelivered infinitely if an exception is thrown in my MDB (and it thus rolls back). This despite my messaging-service.xml explicitly limiting redeliveries to 3 (DefaultMaxDeliveryAttempts = 3). When no exceptions occur (which is the normal case), everything runs fine. I've looked around for answers but this one keeps boggling my mind.

       

      My JBoss 5.1 server is connected to a Websphere MQ server using a resource adapter (similar to these steps and/or these steps). My MDB is all defined in XML (and not using annotations) as I'd like to keep the code as JBoss-independent as possible.

       

      Any help is appreciated! I'd be happy to provide more information if needed.

       

      Here are snippets from relevant files:

       

      jboss.xml

      {code:xml}

      <message-driven>

                <ejb-name>MQChannelListener</ejb-name>

                <destination-jndi-name>queue/ReplyQueue</destination-jndi-name>

                <resource-adapter-name>wmq.jmsra.rar</resource-adapter-name>

      </message-driven>

      {code:xml}

       

      ejb-jar.xml

      {code:xml}

          <message-driven>

            <ejb-name>MQChannelListener</ejb-name>

            <ejb-class>path.to.class.MQChannelListener</ejb-class>

            <messaging-type>javax.jms.MessageListener</messaging-type>

            <transaction-type>Container</transaction-type>

            <activation-config>

               <activation-config-property>

                     <activation-config-property-name>destinationType</activation-config-property-name>

                     <activation-config-property-value>javax.jms.Queue</activation-config-property-value>

               </activation-config-property>

               <activation-config-property>

                     <activation-config-property-name>destination</activation-config-property-name>

                     <activation-config-property-value>XXX</activation-config-property-value>

               </activation-config-property>

               <activation-config-property>

                     <activation-config-property-name>channel</activation-config-property-name>

                     <activation-config-property-value>XXX</activation-config-property-value>

               </activation-config-property>

               <activation-config-property>

                     <activation-config-property-name>hostName</activation-config-property-name>

                     <activation-config-property-value>XXX</activation-config-property-value>

               </activation-config-property>

               <activation-config-property>

                     <activation-config-property-name>port</activation-config-property-name>

                     <activation-config-property-value>XXX</activation-config-property-value>

               </activation-config-property>

               <activation-config-property>

                     <activation-config-property-name>queueManager</activation-config-property-name>

                     <activation-config-property-value>XXX</activation-config-property-value>

               </activation-config-property>

               <activation-config-property>

                     <activation-config-property-name>transportType</activation-config-property-name>

                     <activation-config-property-value>CLIENT</activation-config-property-value>

               </activation-config-property>

               <activation-config-property>

                     <activation-config-property-name>useJNDI</activation-config-property-name>

                     <activation-config-property-value>false</activation-config-property-value>

               </activation-config-property>

           </activation-config>

          </message-driven>

      ...

                 <container-transaction>

                          <method>

                                    <ejb-name>MQChannelListener</ejb-name>

                                    <method-name>*</method-name>

                          </method>

                          <trans-attribute>RequiresNew</trans-attribute>

                </container-transaction>

      {code:xml}

       

      MQChannelListener.java

      {code:java}

      public class MQChannelListener implements MessageListener {

       

                @PersistenceContext(unitName = "persistence-context")

                private EntityManager entityManager;

       

                @Resource

                private MessageDrivenContext sessionContext;

       

                @Override

                public void onMessage(Message msg) {

                          String textMsg = null, messageId = null;

                          long timestamp = -1;

                          boolean redelivered = false;

                          try {

                                    textMsg = ((TextMessage) msg).getText();

                                    messageId = msg.getJMSMessageID();

                                    timestamp = msg.getJMSTimestamp();

                                    redelivered = msg.getJMSRedelivered();

                                    // perform code

                          } catch (Throwable t) {

                                    sessionContext.setRollbackOnly();

                          }

                }

      }

      {code:java}

       

      wmq.jmsra-ds.xml

      {code:xml}

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

      <connection-factories>

        <tx-connection-factory>

          <jndi-name>queue/WMSRACF</jndi-name>

          <xa-transaction />

          <rar-name>wmq.jmsra.rar</rar-name>

          <connection-definition>javax.jms.ConnectionFactory</connection-definition>

          <config-property name="channel" type="java.lang.String">XXX</config-property>

          <config-property name="hostName" type="java.lang.String">XXX</config-property>

          <config-property name="port" type="java.lang.String">XXX</config-property>

          <config-property name="queueManager" type="java.lang.String">XXX</config-property>

          <config-property name="transportType" type="java.lang.String">CLIENT</config-property>

          <config-property name="xaEnabled" type="java.lang.String">true</config-property>

          <max-pool-size>100</max-pool-size>

          <track-connection-by-tx>true</track-connection-by-tx>

        </tx-connection-factory>

        <mbean code="org.jboss.resource.deployment.AdminObject" name="jca.wmq:name=RequestQueue">

            <attribute name="JNDIName">queue/RequestQueue</attribute>

          <depends optional-attribute-name="RARName">

            jboss.jca:service=RARDeployment,name='wmq.jmsra.rar'

          </depends>

          <attribute name="Type">javax.jms.Queue</attribute>

          <attribute name="Properties">

            baseQueueManagerName=XXX

            baseQueueName=XXX

          </attribute>

        </mbean>

      </connection-factories>

      {code:xml}

       

      messaging-service.xlm

      {code:xml}

      <server>

         <mbean code="org.jboss.jms.server.ServerPeer"

            name="jboss.messaging:service=ServerPeer"

            xmbean-dd="xmdesc/ServerPeer-xmbean.xml">

            <attribute name="ServerPeerID">0</attribute>

            <attribute name="DefaultQueueJNDIContext">/queue</attribute>

            <attribute name="DefaultTopicJNDIContext">/topic</attribute>

            <attribute name="PostOffice">jboss.messaging:service=PostOffice</attribute>

            <attribute name="DefaultDLQ">jboss.messaging.destination:service=Queue,name=DLQ</attribute>

            <attribute name="DefaultMaxDeliveryAttempts">3</attribute>

            <attribute name="DefaultExpiryQueue">jboss.messaging.destination:service=Queue,name=ExpiryQueue</attribute>

            <attribute name="DefaultRedeliveryDelay">5000</attribute>

            <attribute name="MessageCounterSamplePeriod">5000</attribute>

            <attribute name="FailoverStartTimeout">60000</attribute>

            <attribute name="FailoverCompleteTimeout">300000</attribute>

            <attribute name="StrictTck">false</attribute>

            <attribute name="DefaultMessageCounterHistoryDayLimit">-1</attribute>

            <attribute name="ClusterPullConnectionFactoryName">jboss.messaging.connectionfactory:service=ClusterPullConnectionFactory</attribute>

            <attribute name="DefaultPreserveOrdering">false</attribute>

            <attribute name="RecoverDeliveriesTimeout">300000</attribute>

            <attribute name="EnableMessageCounters">false</attribute>

            <depends optional-attribute-name="PersistenceManager">jboss.messaging:service=PersistenceManager</depends>

            <depends optional-attribute-name="JMSUserManager">jboss.messaging:service=JMSUserManager</depends>

            <depends>jboss.messaging:service=Connector,transport=bisocket</depends>

            <depends optional-attribute-name="SecurityStore"

                proxy-type="org.jboss.jms.server.SecurityStore">jboss.messaging:service=SecurityStore</depends>

         </mbean>

      </server>

      {code:xml}

       

      Note: Snippets were modified slightly for compression and security.

       

      Can anyone spot what I'm doing wrong/missing?

       

      Thanks!