0 Replies Latest reply on May 1, 2011 3:10 AM by wdorninger

    Websphere MQ (MQSeries) JCA adapter, JBoss Connection pooling, setMessageListener

    wdorninger

      Hi JBoss and MQSeries users,

       

      I have a question related to JBoss 4.2.3 and integrating MQSeries 6.x/7.x (i tried now both) and MessageDrivenBeans. I did setup the JCA connector for MQ Series outlined below. I'm using XA as well. Now the problem I have is JBoss uses connection pools that seem to call setMessageListener on the javax.jms.Session object. Initially i thought i can work around this probelm by not using the StdJMSPool (and using org.jboss.ejb.plugins.inflow.JBossJMSMessageEndpointFactory instead of org.jboss.ejb.plugins.jms.JMSContainerInvoker) but it seems both do call setMessageListener and consequently I get an error like the following (see the exeption further down). Also - it seems that JBoss is using setMessageListener to hook up the Message with the XA transaction. As far as I understand setMessageListener on Session/Destinations is optional according to the Java spec - so there are JCA connectors (if used as wrapper for JMS) that won't implement this.

       

      Is there a way to avoid this behavior (setMessageListener)? - I have seen that other posters got this working but after having read almost all posts and googling for a day to find a solution I have given up and came to the conclusion that I must be doing something wrong. Also my setup is working when not using MDB's (e.g. when enqueuing messages) but when using MDBs and the associated JBoss connection pooling things go sour.

       

      Any help appreciated, Thanks in advance

      Walter

       

      11:15:35,646 ERROR [JmsActivation] Unable to reconnect org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@1b829c7(ra=org.jboss.resource.adapter.jms.JmsResourceAdapter@12c0b3f destination=queue/TESTQUEUE isTopic=false tx=true durable=false reconnect=10 provider=DefaultJMSProvider user=null maxMessages=1 minSession=1 maxSession=15 keepAlive=60000 useDLQ=false)

      com.ibm.msg.client.jms.DetailedIllegalStateException: MQJCA1024: The session must not have a message listener. An application attempted to set a message listener for a JMS session.  Modify the application so that it does not use a message listener.

              at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:149)

              at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:86)

              at com.ibm.mq.connector.outbound.SessionWrapper.setMessageListener(SessionWrapper.java:345)

              at org.jboss.resource.adapter.jms.inflow.JmsServerSession.setup(JmsServerSession.java:128)

              at org.jboss.resource.adapter.jms.inflow.JmsServerSessionPool.setupSessions(JmsServerSessionPool.java:197)

              at org.jboss.resource.adapter.jms.inflow.JmsServerSessionPool.start(JmsServerSessionPool.java:88)

              at org.jboss.resource.adapter.jms.inflow.JmsActivation.setupSessionPool(JmsActivation.java:585)

              at org.jboss.resource.adapter.jms.inflow.JmsActivation.setup(JmsActivation.java:323)

              at org.jboss.resource.adapter.jms.inflow.JmsActivation.handleFailure(JmsActivation.java:259)

              at org.jboss.resource.adapter.jms.inflow.JmsActivation$SetupActivation.run(JmsActivation.java:639)

              at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)

              at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)

              at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)

              at java.lang.Thread.run(Thread.java:619)

       

       

      Code from org.jboss.resource.adapter.jms.inflow.JmsServerSession.java:

      [...]

      // Get the endpoint
            MessageEndpointFactory endpointFactory = activation.getMessageEndpointFactory();

            XAResource xaResource = null;

            if (activation.isDeliveryTransacted() && xaSession != null)

               xaResource = xaSession.getXAResource();

            endpoint = endpointFactory.createEndpoint(xaResource);

           

            // Set the message listener
            session.setMessageListener(this);

         }

      [...]

       

      Code from Std StdServerSession which i used before (StdJMSPool)

      [...]

            if (log.isDebugEnabled())

               log.debug("initializing (pool, session, xaSession, useLocalTX): " +

                  pool + ", " + session + ", " + xaSession + ", " + useLocalTX);

           

            // Set out self as message listener
            if (xaSession != null)

              xaSession.setMessageListener(this);

            else

              session.setMessageListener(this);

           

            InitialContext ctx = null;

      [...]

       

       

      My MQ JCA configuration

       

        <tx-connection-factory>

          <jndi-name>MQConnectionFactory</jndi-name>

          <xa-transaction/>

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

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

          <config-property name="channel" type="java.lang.String">SYSTEM.DEF.SVRCONN</config-property>

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

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

          <config-property name="queueManager" type="java.lang.String">default.queue.manager</config-property>

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

          <config-property name="username" type="java.lang.String">user</config-property>

          <config-property name="password" type="java.lang.String">gsource</config-property>

          <security-domain-and-application>JmsXARealm</security-domain-and-application>

        </tx-connection-factory>

       

        <mbean code="org.jboss.resource.deployment.AdminObject"

            name="jca.wmq:name=TESTQUEUE">

          <attribute name="JNDIName">queue/TESTQUEUE</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=default.queue.manager

            baseQueueName=TESTQUEUE

          </attribute>

        </mbean>

       

        <mbean code="org.jboss.resource.deployment.AdminObject"

            name="jca.wmq:name=TESTDLQ">

          <attribute name="JNDIName">queue/TESTDLQ</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=default.queue.manager

            baseQueueName=TESTDLQ

          </attribute>

        </mbean> 

       

        <mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="jboss.mq:service=JMSProviderLoader,name=WSMQJMSProvider">

          <attribute name="ProviderName">DefaultJMSProvider</attribute>

          <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>

          <attribute name="QueueFactoryRef">java:/MQConnectionFactory</attribute>

          <attribute name="TopicFactoryRef">java:/MQConnectionFactory</attribute>

        </mbean>