use of org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig in project activemq-artemis by apache.
the class RecoveryManager method register.
public XARecoveryConfig register(ActiveMQConnectionFactory factory, String userName, String password, Map<String, String> properties) {
ActiveMQRALogger.LOGGER.debug("registering recovery for factory : " + factory);
XARecoveryConfig config = XARecoveryConfig.newConfig(factory, userName, password, properties);
resources.add(config);
if (registry != null) {
registry.register(config);
}
return config;
}
use of org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig in project activemq-artemis by apache.
the class HornetQProtocolManagerTest method testLegacy.
@Test
public void testLegacy() throws Exception {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616?protocolManagerFactoryStr=" + HornetQClientProtocolManagerFactory.class.getName());
connectionFactory.createConnection().close();
ActiveMQConnectionFactory connectionFactory2 = new ActiveMQConnectionFactory("tcp://localhost:61617");
connectionFactory2.createConnection().close();
RecoveryManager manager = new RecoveryManager();
manager.register(connectionFactory, null, null, new ConcurrentHashMap<String, String>());
manager.register(connectionFactory2, null, null, new ConcurrentHashMap<String, String>());
for (XARecoveryConfig resource : manager.getResources()) {
try (ServerLocator locator = resource.createServerLocator();
ClientSessionFactory factory = locator.createSessionFactory();
ClientSession session = factory.createSession()) {
// Nothing
}
}
}
use of org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig in project activemq-artemis by apache.
the class ResourceAdapterTest method testStartStopActivationManyTimes.
@Test
public void testStartStopActivationManyTimes() throws Exception {
ServerLocator locator = createInVMNonHALocator();
ClientSessionFactory factory = locator.createSessionFactory();
ClientSession session = factory.createSession(false, false, false);
ActiveMQDestination queue = (ActiveMQDestination) ActiveMQJMSClient.createQueue("test");
session.createQueue(queue.getSimpleAddress(), queue.getSimpleAddress(), true);
session.close();
ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
ra.setConnectorClassName(INVM_CONNECTOR_FACTORY);
ra.setUserName("userGlobal");
ra.setPassword("passwordGlobal");
ra.start(new BootstrapContext());
Connection conn = ra.getDefaultActiveMQConnectionFactory().createConnection();
conn.close();
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
spec.setResourceAdapter(ra);
spec.setUseJNDI(false);
spec.setUser("user");
spec.setPassword("password");
spec.setDestinationType("javax.jms.Topic");
spec.setDestination("test");
spec.setMinSession(1);
spec.setMaxSession(15);
ActiveMQActivation activation = new ActiveMQActivation(ra, new MessageEndpointFactory(), spec);
ServerLocatorImpl serverLocator = (ServerLocatorImpl) ra.getDefaultActiveMQConnectionFactory().getServerLocator();
Set<XARecoveryConfig> resources = ra.getRecoveryManager().getResources();
for (int i = 0; i < 10; i++) {
System.out.println(i);
activation.start();
assertEquals(1, resources.size());
activation.stop();
}
ra.stop();
assertEquals(0, resources.size());
locator.close();
}
use of org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig in project activemq-artemis by apache.
the class XARecoveryConfigTest method testEquals.
@Test
public void testEquals() throws Exception {
String factClass = "org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory";
TransportConfiguration transportConfig = new TransportConfiguration(factClass, null);
XARecoveryConfig config = new XARecoveryConfig(false, new TransportConfiguration[] { transportConfig }, null, null, null);
TransportConfiguration transportConfig2 = new TransportConfiguration(factClass, null);
XARecoveryConfig config2 = new XARecoveryConfig(false, new TransportConfiguration[] { transportConfig2 }, null, null, null);
// They are using Different names
Assert.assertNotEquals(transportConfig, transportConfig2);
Assert.assertEquals(transportConfig.newTransportConfig(""), transportConfig2.newTransportConfig(""));
// The equals here shouldn't take the name into consideration
Assert.assertEquals(config, config2);
}
use of org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig in project activemq-artemis by apache.
the class XARecoveryConfigTest method testNotEquals.
@Test
public void testNotEquals() throws Exception {
String factClass = "org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory";
TransportConfiguration transportConfig = new TransportConfiguration(factClass, null);
XARecoveryConfig config = new XARecoveryConfig(false, new TransportConfiguration[] { transportConfig }, null, null, null);
TransportConfiguration transportConfig2 = new TransportConfiguration(factClass + "2", null);
XARecoveryConfig config2 = new XARecoveryConfig(false, new TransportConfiguration[] { transportConfig2 }, null, null, null);
// They are using Different names
Assert.assertNotEquals(transportConfig, transportConfig2);
Assert.assertNotEquals(transportConfig.newTransportConfig(""), transportConfig2.newTransportConfig(""));
// The equals here shouldn't take the name into consideration
Assert.assertNotEquals(config, config2);
}
Aggregations