Search in sources :

Example 1 with DummyTransactionManager

use of org.apache.activemq.artemis.tests.integration.ra.DummyTransactionManager in project activemq-artemis by apache.

the class JMSBridgeReconnectionTest method performCrashAndReconnect.

private void performCrashAndReconnect(boolean restart) throws Exception {
    cff1xa = new ConnectionFactoryFactory() {

        @Override
        public Object createConnectionFactory() throws Exception {
            ActiveMQXAConnectionFactory cf = (ActiveMQXAConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.XA_CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY, params1));
            // Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
            cf.setReconnectAttempts(-1);
            cf.setBlockOnNonDurableSend(true);
            cf.setBlockOnDurableSend(true);
            cf.setCacheLargeMessagesClient(true);
            return cf;
        }
    };
    DummyTransactionManager tm = new DummyTransactionManager();
    DummyTransaction tx = new DummyTransaction();
    tm.tx = tx;
    JMSBridgeImpl bridge = new JMSBridgeImpl(cff0xa, cff1xa, sourceQueueFactory, targetQueueFactory, null, null, null, null, null, 1000, -1, QualityOfServiceMode.ONCE_AND_ONLY_ONCE, 10, 5000, null, null, false).setBridgeName("test-bridge");
    addActiveMQComponent(bridge);
    bridge.setTransactionManager(tm);
    bridge.start();
    // Now crash the dest server
    JMSBridgeReconnectionTest.log.info("About to crash server");
    jmsServer1.stop();
    if (restart) {
        jmsServer1.start();
    }
    // Wait a while before starting up to simulate the dest being down for a while
    JMSBridgeReconnectionTest.log.info("Waiting 5 secs before bringing server back up");
    Thread.sleep(TIME_WAIT);
    JMSBridgeReconnectionTest.log.info("Done wait");
    bridge.stop();
    if (restart) {
        assertTrue(tx.rolledback);
        assertTrue(tx.targetConnected);
    } else {
        assertTrue(tx.rolledback);
        assertFalse(tx.targetConnected);
    }
}
Also used : DummyTransactionManager(org.apache.activemq.artemis.tests.integration.ra.DummyTransactionManager) JMSBridgeImpl(org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl) ConnectionFactoryFactory(org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) HeuristicRollbackException(javax.transaction.HeuristicRollbackException) SystemException(javax.transaction.SystemException) RollbackException(javax.transaction.RollbackException) HeuristicMixedException(javax.transaction.HeuristicMixedException) ActiveMQXAConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory)

Example 2 with DummyTransactionManager

use of org.apache.activemq.artemis.tests.integration.ra.DummyTransactionManager in project activemq-artemis by apache.

the class JMSBridgeTest method testSetTMClass.

@Test
public void testSetTMClass() throws Exception {
    TransactionManagerLocatorImpl.setTransactionManager(new DummyTransactionManager());
    JMSBridgeImpl bridge = null;
    try {
        bridge = new JMSBridgeImpl(cff0, cff0, sourceQueueFactory, localTargetQueueFactory, null, null, null, null, null, 3000, 10, QualityOfServiceMode.ONCE_AND_ONLY_ONCE, 10000, 3000, null, null, false).setBridgeName("test-bridge");
        bridge.start();
    } finally {
        if (bridge != null) {
            bridge.stop();
        }
    }
}
Also used : DummyTransactionManager(org.apache.activemq.artemis.tests.integration.ra.DummyTransactionManager) JMSBridgeImpl(org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl) Test(org.junit.Test)

Aggregations

JMSBridgeImpl (org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl)2 DummyTransactionManager (org.apache.activemq.artemis.tests.integration.ra.DummyTransactionManager)2 HeuristicMixedException (javax.transaction.HeuristicMixedException)1 HeuristicRollbackException (javax.transaction.HeuristicRollbackException)1 RollbackException (javax.transaction.RollbackException)1 SystemException (javax.transaction.SystemException)1 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)1 ConnectionFactoryFactory (org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory)1 ActiveMQXAConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory)1 Test (org.junit.Test)1