4 Replies Latest reply on Mar 15, 2012 12:17 PM by Pietro Tamborini

    Transaction timeout and MDB message loss

    Pietro Tamborini Newbie

      Hi everyone,

       

      I'm porting a J2EE application, that define MDB's and SSB's,  to JBoss 5.1

      Application connects to PostgresSQL and ActiveMQ (5.4.2 and 5.5.1), using a tow phase commit and a Container managed transaction.

      for activemq we followed best pratices stated in the issue: https://issues.apache.org/jira/browse/AMQ-2670

      What we've found blocking is a strange behaviour when MDB's goes in transaction timeout: activemq lose the message, eventhough transaction is rollbacked.

      I've found a JBOSS https://issues.jboss.org/browse/JBAS-7922 about message loss, but the test case is quite different.

       

      Has someone faced something similar? There are some configuration change that could be applied?

       

       

      Resource configuration.

       

      <datasources>

        <xa-datasource>

          <jndi-name>jdbc/fmbDSwfm</jndi-name>

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

          <xa-datasource-property name="ServerName">127.0.0.1</xa-datasource-property>

          <xa-datasource-property name="PortNumber">5432</xa-datasource-property>

          <xa-datasource-property name="DatabaseName">svi_mm_jboss2</xa-datasource-property>

          <xa-datasource-property name="User">svi_mm_jboss2_user</xa-datasource-property>

         <xa-datasource-property name="Password">svi_mm_jboss2_user</xa-datasource-property>

          <!-- <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> -->

          <xa-datasource-class>org.postgresql.xa.PostgreSqlXaDataSource</xa-datasource-class>

          <idle-timeout-minutes>90</idle-timeout-minutes>

          <xa-resource-timeout>91</xa-resource-timeout>

          <validation>

            <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"></valid-connection-checker>

            <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"></exception-sorter>

          </validation>

          <metadata>

             <type-mapping>PostgreSQL 7.2</type-mapping>

          </metadata>

          <min-pool-size>0</min-pool-size>

         <max-pool-size>30</max-pool-size>

        </xa-datasource>

      </datasources>

       

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

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

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

          <attribute name="Properties">xa=true

          java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory

          java.naming.provider.url=tcp://127.0.0.1:62000

          </attribute>

          <attribute name="QueueFactoryRef">java:/activemq/XAConnectionFactory</attribute>

          <attribute name="TopicFactoryRef">java:/activemq/XAConnectionFactory</attribute>

           <attribute name="FactoryRef">java:/activemq/XAConnectionFactory</attribute>

      </mbean>

       

      <tx-connection-factory>

        <jndi-name>jms/fmbQCF</jndi-name>

        <xa-transaction/>

        <rar-name>activemq-rar-5.5.1.rar</rar-name>

        <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>

        <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/ActiveMQRAR</config-property>

        <min-pool-size>1</min-pool-size>

        <max-pool-size>85</max-pool-size>

        <blocking-timeout-millis>30000</blocking-timeout-millis>

        <idle-timeout-minutes>3</idle-timeout-minutes>

      </tx-connection-factory>

       

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

      <transaction-service>

          <properties name="documentation">

              <!--

              Properties necessarie alla configurazione XA activeMQ + PostgreSQL

              -->

          </properties>

          <properties depends="arjuna" name="jta">

              <!--

              Support subtransactions in the JTA layer?

              Default is NO.

            -->

              <property name="com.arjuna.ats.jta.supportSubtransactions" value="NO"/>

              <property name="com.arjuna.ats.jta.jtaTMImplementation" value="com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple"/>

              <!--

                  com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple

                  -->

              <property name="com.arjuna.ats.jta.jtaUTImplementation" value="com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple"/>

              <!--

                  com.arjuna.ats.internal.jta.transaction.jts.UserTransactionImple

                  -->

              <!-- xaRecoveryNode should match value in nodeIdentifier or be * -->

              <property name="com.arjuna.ats.jta.xaRecoveryNode" value="1"/>   

              <!-- *** Add this line to enable recovery for JMS resources using ACTIVEMQ *** -->

              <!--<property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.ACTIVEMQ" value="org.jboss.jms.server.recovery.MessagingXAResourceRecovery;java:/ActiveMQJMSProvider"/>-->   

              <property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.ACTIVEMQ" value="org.jboss.jms.server.recovery.MessagingXAResourceRecovery;jms/fmbQCF"/>

              <property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.JDBC" value="com.arjuna.ats.internal.jbossatx.jta.AppServerJDBCXARecovery;jdbc/fmbDSwfm"/>

          </properties>

      </transaction-service>  

        • 1. Re: Transaction timeout and MDB message loss
          Tom Jenkinson Master

          Hi Pietro,

           

          Do you have a timeout set on the sent JMS messages?

           

          Are you sure your MDB is using an XA connection?

           

          Have you checked the logs to make sure that the ActiveMQ resource is being enlisted?

           

          I assume you see the database rollback ok?

           

          I assume this all appears to work when you commit.

           

          Tom

          • 2. Re: Transaction timeout and MDB message loss
            Pietro Tamborini Newbie

            Hi Tom,

             

            timeout is setted on Transaction Manager

            about MDB using XA connection I not so sure, I'm pretty sure about Postreges connection 'cause no changed is found on DB

            I'm not sure about ActiveMQ.

            MDB is producing message to other queue, using the connection factory conf attached above, this message are not found on the Qmanager

            so I suppose they were rolledback.

            I've tried to attach the JMSProviderLoader I posted to MDB invoker bindings with no changes. Message read from MDB are lost

             

            I've logged arjuna and activemq ra  but I've not found the enlisting of ActiveMQ resource, maybe I'm tracing the wrong package.

            • 3. Re: Transaction timeout and MDB message loss
              Tom Jenkinson Master

              I think it is important to make sure that you have configured the MDB to use the XA connection factory.

               

              Do you have some code fragment to illustrate your MDB's binding to its CF?

              • 4. Re: Transaction timeout and MDB message loss
                Pietro Tamborini Newbie

                Myabe I've done wrong but I tried to do that configuration setting the into MDB's the configuration for new inflow container provider

                 

                <message-driven>

                            <ejb-name>J1.EAR.RECOVERY.QUEUE</ejb-name>

                            <local-jndi-name>jms/it/nch/J1.EAR.RECOVERY.QUEUE</local-jndi-name>

                            <resource-adapter-name>activemq-rar-5.4.2.rar</resource-adapter-name>

                            <configuration-name>ActiveMQ Message Driven Bean</configuration-name>

                .....

                 

                and define it in stardardjboss.xml with the invoker-bindings that link the JMSProvider loader of my previuos post

                 

                <container-configuration>

                <container-name>ActiveMQ Message Driven Bean</container-name>

                <call-logging>false</call-logging>

                <invoker-proxy-binding-name>activemq-message-driven-bean</invoker-proxy-binding-name>

                <container-interceptors>

                  <interceptor metricsEnabled="false" transaction="Both">org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>

                  <interceptor metricsEnabled="false" transaction="Both">org.jboss.ejb.plugins.LogInterceptor</interceptor>

                  <interceptor metricsEnabled="false" transaction="Both">org.jboss.ejb.plugins.RunAsSecurityInterceptor</interceptor>

                  <interceptor metricsEnabled="false" transaction="Container">org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>

                  <interceptor metricsEnabled="false" transaction="Container">org.jboss.ejb.plugins.CallValidationInterceptor</interceptor>

                <!-- interceptor transaction="Container" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor-->

                  <interceptor metricsEnabled="false" transaction="Container">org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor</interceptor>

                  <interceptor transaction="Bean">org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor</interceptor>

                  <interceptor transaction="Bean">org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT</interceptor>

                  <interceptor transaction="Bean">org.jboss.ejb.plugins.CallValidationInterceptor</interceptor>

                <!-- interceptor transaction="Bean" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor-->

                  <interceptor metricsEnabled="false" transaction="Both">org.jboss.resource.connectionmanager.CachedConnectionInterceptor</interceptor>

                </container-interceptors> <instance-pool>org.jboss.ejb.plugins.MessageDrivenInstancePool</instance-pool>

                <container-pool-conf>

                   <MaximumSize>100</MaximumSize>

                   <strictMaximumSize>true</strictMaximumSize>

                </container-pool-conf>

                </container-configuration>

                 

                -<invoker-proxy-binding>

                   <name>activemq-message-driven-bean</name>

                   <invoker-mbean>default</invoker-mbean>

                   <proxy-factory>org.jboss.ejb.plugins.inflow.JBossJMSMessageEndpointFactory</proxy-factory>

                   <proxy-factory-config>

                     <endpoint-interceptors>

                        <interceptor metricsEnabled="false" transaction="Both">org.jboss.proxy.ClientMethodInterceptor</interceptor>

                        <interceptor metricsEnabled="false" transaction="Both">org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor</interceptor>

                        <interceptor metricsEnabled="false" transaction="Both">org.jboss.proxy.TransactionInterceptor</interceptor>

                        <interceptor metricsEnabled="false" transaction="Both">org.jboss.invocation.InvokerInterceptor</interceptor>

                     </endpoint-interceptors>

                    <JMSProviderAdapterJNDI>ActiveMQRAR</JMSProviderAdapterJNDI> <!-- the JMSProvider difining ActiveMQ XA  ConnectionFacotry-->

                  </proxy-factory-config>

                </invoker-proxy-binding>