3 Replies Latest reply on Sep 29, 2006 12:11 PM by rrkraft

    XA trasactions over a remote MQ queue Jboss 3.2.6

    tnine

      I?m having some issue reading transitionally from a remote JBoss MQ Queue. I have configured the remote queue with the configuration defined here.

      http://wiki.jboss.org/wiki/Wiki.jsp?page=HowDoIConfigureTheJMSResourceAdapterToUseARemoteConnectionFactory

      With the exception of the following change in our ?ds.xml file

       <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
       name="jboss.mq:service=JMSProviderLoader,name=RemoteJMSProvider,server=sun9.ata.com">
       <attribute name="ProviderName">ATADevJMSProvider</attribute>
       <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
       <!-- The queue connection factory -->
       <attribute name="QueueFactoryRef">XAConnectionFactory</attribute>
       <!-- The topic factory -->
      <attribute name="TopicFactoryRef">XAConnectionFactory</attribute>
       <!-- Uncomment to use HAJNDI to access JMS -->
       <attribute name="Properties">
       java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
       java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
       java.naming.provider.url=jnp://sun9:7045
       </attribute>
       </mbean>
      



      We have the following code in our MDB

      public void onMessage(Message message) {
       // MessageDrivenContext
      
       try {
       getDelegator().delegate(message);
       } catch (MessageDelegationException e) {
       LOGGER.fatal(e);
       // roll back the transaction
       if (!this.getMessageDrivenContext().getRollbackOnly()) {
       this.getMessageDrivenContext().setRollbackOnly();
       }
       }
      
       }
      


      And this ejb-jar.xml

      <message-driven>
       <description>
       Bean to access messages from cats queues
       </description>
       <display-name>CATSMessageAccess</display-name>
      
       <ejb-name>ejb/CATSMessageAccess</ejb-name>
      
       <ejb-class>
       com.ata.utilities.mdd.MessageAccessBean
       </ejb-class>
      
       <transaction-type>Container</transaction-type>
       <acknowledge-mode>Auto-acknowledge</acknowledge-mode>
      
       <message-driven-destination>
       <destination-type>javax.jms.Queue</destination-type>
       </message-driven-destination>
      
       </message-driven>
      
      


      If the POJO code fails by throwing an exception and the message tries to roll back the transaction, I get this exception and the message is removed from the queue on the remote server.

      21:10:02,765 INFO [STDOUT] 21:10:02,765 INFO [SessionFactoryImpl] closing
      21:10:02,765 ERROR [LogInterceptor] RuntimeException in method: public abstract void javax.jms.Messa
      geListener.onMessage(javax.jms.Message)
      java.lang.IllegalStateException: getRollbackOnly must only be called in the context of a transaction
       (EJB 2.0 - 15.5.1)
       at org.jboss.ejb.MessageDrivenEnterpriseContext$MessageDrivenContextImpl.getRollbackOnly(MessageDri
      venEnterpriseContext.java:192)
       at com.ata.utilities.mdd.MessageAccessBean.onMessage(MessageAccessBean.java:78)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:458
      )
      
      




      I thought I should be running in an XA container transaction, so when I roll back on my MDB, my local JDBC transactions do not commit (that works), and the read from the remote queue should roll back. Why am I not running in a transaction, and why does my remote queue lose the message? I?m assuming once I fix the local transaction problem, that the reading from the queue will succeed. Any help would be greatly apprecaited. I can't seem to find anything in the doc that would explain something I've missed. Reading from the queue works perfectly, it just doesn't happen in a transaction as expected.

      Thanks,
      Todd


        • 1. Re: XA trasactions over a remote MQ queue Jboss 3.2.6
          rrkraft

          We're still having this issue and I'm trouble-shooting it at the JBoss server side. My configuration is as follows:
          standardjboss.xml:
          <invoker-proxy-binding>
          ATADev-mdb-invoker
          <invoker-mbean>does-not-matter</invoker-mbean>
          <proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-fac
          tory>
          <proxy-factory-config>
          ATADevJMSProvider
          StdJMSPool</ServerSessionPoolFactoryJN
          DI>
          1
          30000
          15
          1

          10

          queue/DLQ
          10
          0


          </proxy-factory-config>
          </invoker-proxy-binding>

          <message-driven>
          <ejb-name>ejb/PRCMessageAccess</ejb-name> <destination-jndi-name>queue/PRCCustomerContactForm</destination-jndi-n
          ame>
          <invoker-bindings>

          <invoker-proxy-binding-name>ATADev-mdb-invoker</invoker-proxy-bin
          ding-name>

          </message-driven>

          ?-jms-ds.xml:
          <connection-factories>
          <tx-connection-factory>
          <jndi-name>ATADevJmsXA</jndi-name>
          <xa-transaction/>
          <adapter-display-name>JMS Adapter</adapter-display-name>
          <config-property name="SessionDefaultType" type="java.lang.String">javax.jms
          .Queue</config-property>
          <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:
          /ATADevJMSProvider</config-property>
          <security-domain-and-application>ATADevJmsXARealm</security-domain-and-appli
          cation>

          </tx-connection-factory>
          </connection-factories>

          ?-ds.xml:

          ATADevJMSProvider
          org.jboss.jms.jndi.JNDIProviderAdapte
          r
          <!-- The queue connection factory -->
          java:/ATADevJmsXA
          <!-- The topic factory -->
          XAConnectionFactory
          <!-- Uncomment to use HAJNDI to access JMS -->

          java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
          java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
          java.naming.provider.url=jnp://sun9.ata.com:7045



          login-config.xml:
          <application-policy name = "ATADevJmsXARealm">

          <login-module code = "org.jboss.resource.security.ConfiguredIdentityLo
          ginModule"
          flag = "required">
          <module-option name = "principal">ppppp/module-option>
          <module-option name = "userName">uuuuu</module-option>
          <module-option name = "password">pppppp</module-option>
          <module-option name = "managedConnectionFactoryName">jboss.jca:serv
          ice=TxCM,name=ATADevJmsXA</module-option>
          </login-module>

          </application-policy>

          If we use in ?-ds.xml as attribute name="QueueFactoryRef" XAConnectionFactory, we get the error, Todd mentions.
          If we use there java:/XAConnectionFactory" I get the error "user uuuuu not authenticated".

          I found somewhere, that I could use also a JCA connection factory (java:/ATADevJmsXA), but with this I get "Can not get a topic session from a queue connection".

          I googled and searched the jboss website and cannot find any indication how this should work. I assume since I have a password protected queue, I have to use a JCA connection factory.

          Very Best Regards,
          Rainer





          • 2. Re: XA trasactions over a remote MQ queue Jboss 3.2.6
            rrkraft

            We're still having this issue and I'm trouble-shooting it at the JBoss server side. My configuration is as follows:
            standardjboss.xml:


            <invoker-proxy-binding>
            <name>ATADev-mdb-invoker</name>
            <invoker-mbean>does-not-matter</invoker-mbean>
            <proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-fac
            tory>
            <proxy-factory-config>
            <JMSProviderAdapterJNDI>ATADevJMSProvider</JMSProviderAdapterJNDI>
            <ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJN
            DI>
            <MinimumSize>1</MinimumSize>
            <KeepAliveMillis>30000</KeepAliveMillis>
            <MaximumSize>15</MaximumSize>
            <MaxMessages>1</MaxMessages>
            <MDBConfig>
            <ReconnectIntervalSec>10</ReconnectIntervalSec>
            <DLQConfig>
            <DestinationQueue>queue/DLQ</DestinationQueue>
            <MaxTimesRedelivered>10</MaxTimesRedelivered>
            <TimeToLive>0</TimeToLive>
            </DLQConfig>
            </MDBConfig>
            </proxy-factory-config>
            </invoker-proxy-binding>

            <message-driven>
            <ejb-name>ejb/PRCMessageAccess</ejb-name> <destination-jndi-name>queue/PRCCustomerContactForm</destination-jndi-n
            ame>
            <invoker-bindings>
            <invoker>
            <invoker-proxy-binding-name>ATADev-mdb-invoker</invoker-proxy-bin
            ding-name>
            </invoker>
            </message-driven>


            ?-jms-ds.xml:

            <connection-factories>
            <tx-connection-factory>
            <jndi-name>ATADevJmsXA</jndi-name>
            <xa-transaction/>
            <adapter-display-name>JMS Adapter</adapter-display-name>
            <config-property name="SessionDefaultType" type="java.lang.String">javax.jms
            .Queue</config-property>
            <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:
            /ATADevJMSProvider</config-property>
            <security-domain-and-application>ATADevJmsXARealm</security-domain-and-appli
            cation>

            </tx-connection-factory>
            </connection-factories>


            ?-ds.xml:

            <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
            name="jboss.mq:service=JMSProviderLoader,name=RemoteJMSProvider,server=
            sun9.ata.com">
            <attribute name="ProviderName">ATADevJMSProvider</attribute>
            <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapte
            r</attribute>
            <!-- The queue connection factory -->
            <attribute name="QueueFactoryRef">java:/ATADevJmsXA</attribute>
            <!-- The topic factory -->
            <attribute name="TopicFactoryRef">XAConnectionFactory</attribute>
            <!-- Uncomment to use HAJNDI to access JMS -->
            <attribute name="Properties">
            java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
            java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
            java.naming.provider.url=jnp://sun9.ata.com:7045
            </attribute>
            </mbean>


            login-config.xml:

            <application-policy name = "ATADevJmsXARealm">
            <authentication>
            <login-module code = "org.jboss.resource.security.ConfiguredIdentityLo
            ginModule"
            flag = "required">
            <module-option name = "principal">ppppp/module-option>
            <module-option name = "userName">uuuuu</module-option>
            <module-option name = "password">pppppp</module-option>
            <module-option name = "managedConnectionFactoryName">jboss.jca:serv
            ice=TxCM,name=ATADevJmsXA</module-option>
            </login-module>
            </authentication>
            </application-policy>


            If we use in ?-ds.xml as attribute name="QueueFactoryRef" XAConnectionFactory, we get the error, Todd mentions.
            If we use there java:/XAConnectionFactory" I get the error "user uuuuu not authenticated".

            I found somewhere, that I could use also a JCA connection factory (java:/ATADevJmsXA), but with this I get "Can not get a topic session from a queue connection".

            I googled and searched the jboss website and cannot find any indication how this should work. I assume since I have a password protected queue, I have to use a JCA connection factory.

            Very Best Regards,
            Rainer

            PS: Sorry for the other post. I had to learn first how to quote.




            • 3. Re: XA trasactions over a remote MQ queue Jboss 3.2.6
              rrkraft

              We're still having this issue and I'm trouble-shooting it at the JBoss server side. My configuration is as follows:
              standardjboss.xml:

              <invoker-proxy-binding>
               <name>ATADev-mdb-invoker</name>
               <invoker-mbean>does-not-matter</invoker-mbean>
               <proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-fac
              tory>
               <proxy-factory-config>
               <JMSProviderAdapterJNDI>ATADevJMSProvider</JMSProviderAdapterJNDI>
               <ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJN
              DI>
               <MinimumSize>1</MinimumSize>
               <KeepAliveMillis>30000</KeepAliveMillis>
               <MaximumSize>15</MaximumSize>
               <MaxMessages>1</MaxMessages>
               <MDBConfig>
               <ReconnectIntervalSec>10</ReconnectIntervalSec>
               <DLQConfig>
               <DestinationQueue>queue/DLQ</DestinationQueue>
               <MaxTimesRedelivered>10</MaxTimesRedelivered>
               <TimeToLive>0</TimeToLive>
               </DLQConfig>
               </MDBConfig>
               </proxy-factory-config>
               </invoker-proxy-binding>
              
               <message-driven>
               <ejb-name>ejb/PRCMessageAccess</ejb-name> <destination-jndi-name>queue/PRCCustomerContactForm</destination-jndi-n
              ame>
               <invoker-bindings>
               <invoker>
               <invoker-proxy-binding-name>ATADev-mdb-invoker</invoker-proxy-bin
              ding-name>
               </invoker>
               </message-driven>
              


              ?-jms-ds.xml:
              <connection-factories>
               <tx-connection-factory>
               <jndi-name>ATADevJmsXA</jndi-name>
               <xa-transaction/>
               <adapter-display-name>JMS Adapter</adapter-display-name>
               <config-property name="SessionDefaultType" type="java.lang.String">javax.jms
              .Queue</config-property>
               <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:
              /ATADevJMSProvider</config-property>
               <security-domain-and-application>ATADevJmsXARealm</security-domain-and-appli
              cation>
              
               </tx-connection-factory>
              </connection-factories>
              


              ?-ds.xml:
               <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
               name="jboss.mq:service=JMSProviderLoader,name=RemoteJMSProvider,server=
              sun9.ata.com">
               <attribute name="ProviderName">ATADevJMSProvider</attribute>
               <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapte
              r</attribute>
               <!-- The queue connection factory -->
               <attribute name="QueueFactoryRef">java:/ATADevJmsXA</attribute>
               <!-- The topic factory -->
               <attribute name="TopicFactoryRef">XAConnectionFactory</attribute>
               <!-- Uncomment to use HAJNDI to access JMS -->
               <attribute name="Properties">
               java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
               java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
               java.naming.provider.url=jnp://sun9.ata.com:7045
               </attribute>
               </mbean>
              


              login-config.xml:
               <application-policy name = "ATADevJmsXARealm">
               <authentication>
               <login-module code = "org.jboss.resource.security.ConfiguredIdentityLo
              ginModule"
               flag = "required">
               <module-option name = "principal">ppppp/module-option>
               <module-option name = "userName">uuuuu</module-option>
               <module-option name = "password">pppppp</module-option>
               <module-option name = "managedConnectionFactoryName">jboss.jca:serv
              ice=TxCM,name=ATADevJmsXA</module-option>
               </login-module>
               </authentication>
               </application-policy>
              


              If we use in ?-ds.xml as attribute name="QueueFactoryRef" XAConnectionFactory, we get the error, Todd mentions.
              If we use there java:/XAConnectionFactory" I get the error "user uuuuu not authenticated".

              I found somewhere, that I could use also a JCA connection factory (java:/ATADevJmsXA), but with this I get "Can not get a topic session from a queue connection".

              I googled and searched the jboss website and cannot find any indication how this should work. I assume since I have a password protected queue, I have to use a JCA connection factory.

              Very Best Regards,
              Rainer

              PS: Sorry for the other post. I had to learn first how to quote.