0 Replies Latest reply on May 22, 2013 12:31 PM by frankfrench

    JBoss 7 sqlserver transactions over 2 xa datasources. Only one commits

    frankfrench

      I have a message driven bean that reads from one xa datasource commits to another and then marks the original record as processed. The last operation whilst it appears to be successful when I examine the database I find that the update hasn't been committed.

       

      My standalone xml looks like this

       

       

      ...

       

         </extensions>

       

      <!-- Not sure it I need this -->

          <system-properties>

              <property name="com.arjuna.ats.arjuna.allowMultipleLastResources" value="true"/>

          </system-properties>

       

       

          <management>

       

      <xa-datasource jndi-name="java:/db1" pool-name="db1_pool" enabled="true" use-java-context="true">

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

                              192.168.4.227

                          </xa-datasource-property>

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

                              1433

                          </xa-datasource-property>

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

                              db1

                          </xa-datasource-property>

                          <xa-datasource-property name="SelectMethod">

                              cursor

                          </xa-datasource-property>

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

                              xx

                          </xa-datasource-property>

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

                              xx

                          </xa-datasource-property>

                          <driver>sqlserver</driver>

                      </xa-datasource>

                      <xa-datasource jndi-name="java:/db2" pool-name="db2_pool" enabled="true" use-java-context="true">

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

                              192.168.4.227

                          </xa-datasource-property>

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

                              1433

                          </xa-datasource-property>

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

                              db2

                          </xa-datasource-property>

                          <xa-datasource-property name="SelectMethod">

                              cursor

                          </xa-datasource-property>

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

                              xx

                          </xa-datasource-property>

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

                              xx

                          </xa-datasource-property>

                          <driver>sqlserver</driver>

                      </xa-datasource>


       

                     <drivers>

                          <driver name="sqlserver" module="com.sqlserver">

                              <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>

                          </driver>

                      </drivers>

       

       

      My MDB looks similar to this

       

      @TransactionManagement(TransactionManagementType.CONTAINER)

      @TransactionAttribute(TransactionAttributeType.REQUIRED)

      @MessageDriven(name = "InboundProcessorMDB", activationConfig = {

            @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),

            @ActivationConfigProperty(propertyName = "destination", propertyValue = "Inbound"),

            @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),

            @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1"),

            @ActivationConfigProperty(propertyName = "maxPoolSize", propertyValue = "1")})

      public class InboundProcessor implements MessageListener

      {

         private static Logger log = Logger.getLogger(InboundFormProcessor.class);

       

         private final String DOMAIN = "a_domain";

       

         private static final String SERVER_USERNAME = "server";

       

         @Resource

         private MessageDrivenContext mdc;

       

         @EJB

         private PostOffice

        

         @EJB

         private MessageHandler messageHandler;

       

         public void onMessage(Message message)

         {

       

      //Get Message from db 1 - successful

               PostData post = postOffice.getPostFor(SERVER_USERNAME, DOMAIN);

       

               if (post != null)

               {

      //Process and persist in db2 - successful

                   messageHandler.process(post);

       

      //Mark record in db1 as process. Seem to be successful but never gets comitted

                   postOffice.acknowledgePost(post.getId());

       

                  log.info("Message acknowledged " + post.getId());

               }

       

         }

       

      I have gone round and round in circles on this one. Hence I've ended up here.

       

       

      This has been run on AS 7.1.1.Final & EAP 6.1 Alpha

       

      Same result

       

      The only way to get the second datasource to commit is to annotate the method REQUIRES_NEW but the kind of defeats the object.

       

      Hope someone can help.