use of org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory 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.jms.client.ActiveMQXAConnectionFactory in project activemq-artemis by apache.
the class BridgeTestBase method setUpAdministeredObjects.
protected void setUpAdministeredObjects() throws Exception {
cff0LowProducerWindow = new ConnectionFactoryFactory() {
@Override
public ConnectionFactory createConnectionFactory() throws Exception {
ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
// Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
cf.setReconnectAttempts(0);
cf.setBlockOnNonDurableSend(true);
cf.setBlockOnDurableSend(true);
cf.setCacheLargeMessagesClient(true);
cf.setProducerWindowSize(100);
return cf;
}
};
cff0 = new ConnectionFactoryFactory() {
@Override
public ConnectionFactory createConnectionFactory() throws Exception {
ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
// Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
cf.setReconnectAttempts(0);
cf.setBlockOnNonDurableSend(true);
cf.setBlockOnDurableSend(true);
cf.setCacheLargeMessagesClient(true);
return cf;
}
};
cff0xa = new ConnectionFactoryFactory() {
@Override
public Object createConnectionFactory() throws Exception {
ActiveMQXAConnectionFactory cf = (ActiveMQXAConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.XA_CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
// Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
cf.setReconnectAttempts(0);
cf.setBlockOnNonDurableSend(true);
cf.setBlockOnDurableSend(true);
cf.setCacheLargeMessagesClient(true);
return cf;
}
};
cf0 = (ConnectionFactory) cff0.createConnectionFactory();
cf0xa = (XAConnectionFactory) cff0xa.createConnectionFactory();
cff1 = new ConnectionFactoryFactory() {
@Override
public ConnectionFactory createConnectionFactory() throws Exception {
ActiveMQJMSConnectionFactory cf = (ActiveMQJMSConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.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(0);
cf.setBlockOnNonDurableSend(true);
cf.setBlockOnDurableSend(true);
cf.setCacheLargeMessagesClient(true);
return cf;
}
};
cff1xa = new ConnectionFactoryFactory() {
@Override
public XAConnectionFactory createConnectionFactory() throws Exception {
ActiveMQXAConnectionFactory cf = (ActiveMQXAConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(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(0);
cf.setBlockOnNonDurableSend(true);
cf.setBlockOnDurableSend(true);
cf.setCacheLargeMessagesClient(true);
return cf;
}
};
cf1 = (ConnectionFactory) cff1.createConnectionFactory();
cf1xa = (XAConnectionFactory) cff1xa.createConnectionFactory();
sourceQueueFactory = new DestinationFactory() {
@Override
public Destination createDestination() throws Exception {
return (Destination) context0.lookup("/queue/sourceQueue");
}
};
sourceQueue = (Queue) sourceQueueFactory.createDestination();
targetQueueFactory = new DestinationFactory() {
@Override
public Destination createDestination() throws Exception {
return (Destination) context1.lookup("/queue/targetQueue");
}
};
targetQueue = (Queue) targetQueueFactory.createDestination();
sourceTopicFactory = new DestinationFactory() {
@Override
public Destination createDestination() throws Exception {
return (Destination) context0.lookup("/topic/sourceTopic");
}
};
sourceTopic = (Topic) sourceTopicFactory.createDestination();
localTargetQueueFactory = new DestinationFactory() {
@Override
public Destination createDestination() throws Exception {
return (Destination) context0.lookup("/queue/localTargetQueue");
}
};
localTargetQueue = (Queue) localTargetQueueFactory.createDestination();
}
use of org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory in project activemq-artemis by apache.
the class JMSBridgeTest method testCrashDestStopBridge.
@Test
public void testCrashDestStopBridge() throws Exception {
cff1xa = new ConnectionFactoryFactory() {
@Override
public Object createConnectionFactory() throws Exception {
ActiveMQXAConnectionFactory cf = (ActiveMQXAConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.XA_CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY, params1));
cf.setReconnectAttempts(-1);
cf.setCallFailoverTimeout(-1);
cf.setCallTimeout(10000);
cf.setBlockOnNonDurableSend(true);
cf.setBlockOnDurableSend(true);
cf.setCacheLargeMessagesClient(true);
return cf;
}
};
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(newTransactionManager());
bridge.start();
// Now crash the dest server
JMSBridgeTest.log.info("About to crash server");
jmsServer1.stop();
// Now stop the bridge while the failover is happening
JMSBridgeTest.log.info("About to stop the bridge");
bridge.stop();
// Shutdown the source server
jmsServer0.stop();
}
Aggregations