Search in sources :

Example 1 with XARecoveryConfig

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;
}
Also used : XARecoveryConfig(org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig)

Example 2 with XARecoveryConfig

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
        }
    }
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) RecoveryManager(org.apache.activemq.artemis.ra.recovery.RecoveryManager) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) XARecoveryConfig(org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) Test(org.junit.Test)

Example 3 with XARecoveryConfig

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();
}
Also used : MessageEndpointFactory(org.apache.activemq.artemis.tests.unit.ra.MessageEndpointFactory) ActiveMQActivation(org.apache.activemq.artemis.ra.inflow.ActiveMQActivation) Connection(javax.jms.Connection) XARecoveryConfig(org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig) BootstrapContext(org.apache.activemq.artemis.tests.unit.ra.BootstrapContext) MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint) ActiveMQDestination(org.apache.activemq.artemis.jms.client.ActiveMQDestination) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) ServerLocatorImpl(org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ActiveMQActivationSpec(org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) Test(org.junit.Test)

Example 4 with XARecoveryConfig

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);
}
Also used : XARecoveryConfig(org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Test(org.junit.Test)

Example 5 with XARecoveryConfig

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);
}
Also used : XARecoveryConfig(org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Test(org.junit.Test)

Aggregations

XARecoveryConfig (org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig)5 Test (org.junit.Test)4 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)2 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)2 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)2 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)2 Connection (javax.jms.Connection)1 MessageEndpoint (javax.resource.spi.endpoint.MessageEndpoint)1 ServerLocatorImpl (org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl)1 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)1 ActiveMQDestination (org.apache.activemq.artemis.jms.client.ActiveMQDestination)1 ActiveMQResourceAdapter (org.apache.activemq.artemis.ra.ActiveMQResourceAdapter)1 ActiveMQActivation (org.apache.activemq.artemis.ra.inflow.ActiveMQActivation)1 ActiveMQActivationSpec (org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec)1 RecoveryManager (org.apache.activemq.artemis.ra.recovery.RecoveryManager)1 BootstrapContext (org.apache.activemq.artemis.tests.unit.ra.BootstrapContext)1 MessageEndpointFactory (org.apache.activemq.artemis.tests.unit.ra.MessageEndpointFactory)1