1 Reply Latest reply on Jan 24, 2007 9:29 AM by adrian.brock

    JBoss TS - MQ recovery integration tests

    timfox

      Does anyone know if there are any integration tests that show JBoss TS recovery manager, interacting with JBoss MQ and performing recovery?

      I know there are tests that exercise the XAResource api and call recover() etc manually, but I couldn't see any that actual use JBoss TS to do this.

        • 1. Re: JBoss TS - MQ recovery integration tests

          No there are no tests for this in the testsuite since at the time I wrote
          this JBossTM wasn't integrated into the main build.

          The tests in the testsuite deploy a second copy of JBossMQ into JBossAS
          that I can reboot and test recovery using the XAResource api directly.
          i.e. they are unit tests not integration tests.

          The only test I have is in a private ant project that uses the
          JMSProviderXAResourceRecovery
          with the following change in jbossjta-properties.xml

           <property name="com.arjuna.ats.jta.recovery.XAResourceRecoveryJMS=org.jboss.jta.recovery.jms.JMSProviderXAResourceRecovery;DefaultJMSProvider"/>
          


          It also includes a subclass of the persistence manager
          so I can force the server to crash during commit
          /*
          * JBoss, Home of Professional Open Source
          * Copyright 2006, JBoss Inc., and individual contributors as indicated
          * by the @authors tag. See the copyright.txt in the distribution for a
          * full listing of individual contributors.
          *
          * This is free software; you can redistribute it and/or modify it
          * under the terms of the GNU Lesser General Public License as
          * published by the Free Software Foundation; either version 2.1 of
          * the License, or (at your option) any later version.
          *
          * This software is distributed in the hope that it will be useful,
          * but WITHOUT ANY WARRANTY; without even the implied warranty of
          * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          * Lesser General Public License for more details.
          *
          * You should have received a copy of the GNU Lesser General Public
          * License along with this software; if not, write to the Free
          * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
          * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
          */
          package org.jboss.test.jbossmq;
          
          import javax.jms.JMSException;
          
          import org.jboss.mq.pm.Tx;
          import org.jboss.mq.pm.jdbc2.PersistenceManager;
          
          public class TestPersistenceManager extends PersistenceManager implements TestPersistenceManagerMBean
          {
           private boolean crashInCommit = false;
          
           public TestPersistenceManager() throws JMSException
           {
           }
          
           public boolean getCrashInCommit()
           {
           return crashInCommit;
           }
          
           public void makeCrashInCommit(boolean crashInCommit)
           {
           this.crashInCommit = crashInCommit;
           }
          
           public void commitPersistentTx(Tx txId) throws JMSException
           {
           if (crashInCommit)
           {
           System.out.println("I'm going to crash in 20 seconds");
           try
           {
           Thread.sleep(20000);
           }
           catch (Exception ignored) {}
           Runtime.getRuntime().halt(0);
           }
           else
           super.commitPersistentTx(txId);
           }
          }
          


          The sleep is just to workaround the fact that hypersonic doesn't
          persist data to its transaction log synchronously
          It does it on a timer every 10 seconds. UGLY! :-)