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);
}
}
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();
}
}
}
Aggregations