Search in sources :

Example 46 with ActiveMQResourceAdapter

use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.

the class ResourceAdapterTest method testResourceAdapterSetup.

// https://issues.jboss.org/browse/JBPAPP-5790
@Test
public void testResourceAdapterSetup() throws Exception {
    ActiveMQResourceAdapter adapter = new ActiveMQResourceAdapter();
    adapter.setDiscoveryAddress("231.1.1.1");
    ActiveMQConnectionFactory factory = adapter.getDefaultActiveMQConnectionFactory();
    long initWait = factory.getDiscoveryGroupConfiguration().getDiscoveryInitialWaitTimeout();
    long refresh = factory.getDiscoveryGroupConfiguration().getRefreshTimeout();
    int port = ((UDPBroadcastEndpointFactory) factory.getDiscoveryGroupConfiguration().getBroadcastEndpointFactory()).getGroupPort();
    // defaults
    assertEquals(10000L, refresh);
    assertEquals(10000L, initWait);
    assertEquals(9876, port);
    adapter = new ActiveMQResourceAdapter();
    adapter.setDiscoveryAddress("231.1.1.1");
    adapter.setDiscoveryPort(9876);
    adapter.setDiscoveryRefreshTimeout(1234L);
    factory = adapter.getDefaultActiveMQConnectionFactory();
    initWait = factory.getDiscoveryGroupConfiguration().getDiscoveryInitialWaitTimeout();
    refresh = factory.getDiscoveryGroupConfiguration().getRefreshTimeout();
    // override refresh timeout
    assertEquals(1234L, refresh);
    assertEquals(10000L, initWait);
    adapter = new ActiveMQResourceAdapter();
    adapter.setDiscoveryAddress("231.1.1.1");
    adapter.setDiscoveryPort(9876);
    adapter.setDiscoveryInitialWaitTimeout(9999L);
    factory = adapter.getDefaultActiveMQConnectionFactory();
    initWait = factory.getDiscoveryGroupConfiguration().getDiscoveryInitialWaitTimeout();
    refresh = factory.getDiscoveryGroupConfiguration().getRefreshTimeout();
    // override initial wait
    assertEquals(10000L, refresh);
    assertEquals(9999L, initWait);
    adapter = new ActiveMQResourceAdapter();
    adapter.setDiscoveryAddress("231.1.1.1");
    adapter.setDiscoveryPort(9876);
    adapter.setDiscoveryInitialWaitTimeout(9999L);
    factory = adapter.getDefaultActiveMQConnectionFactory();
    initWait = factory.getDiscoveryGroupConfiguration().getDiscoveryInitialWaitTimeout();
    refresh = factory.getDiscoveryGroupConfiguration().getRefreshTimeout();
    // override initial wait
    assertEquals(10000L, refresh);
    assertEquals(9999L, initWait);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint) Test(org.junit.Test)

Example 47 with ActiveMQResourceAdapter

use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.

the class ResourceAdapterTest method testResourceAdapterSetupOverrideCFParams.

// https://issues.jboss.org/browse/JBPAPP-5836
@Test
public void testResourceAdapterSetupOverrideCFParams() throws Exception {
    ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
    qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
    qResourceAdapter.setConnectionParameters("server-id=0");
    ActiveMQRATestBase.MyBootstrapContext ctx = new ActiveMQRATestBase.MyBootstrapContext();
    qResourceAdapter.start(ctx);
    ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
    spec.setResourceAdapter(qResourceAdapter);
    spec.setUseJNDI(false);
    spec.setDestinationType("javax.jms.Queue");
    spec.setDestination(MDBQUEUE);
    // now override the connector class
    spec.setConnectorClassName(NETTY_CONNECTOR_FACTORY);
    spec.setConnectionParameters("port=61616");
    DummyMessageEndpoint endpoint = new DummyMessageEndpoint(new CountDownLatch(1));
    DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
    qResourceAdapter.endpointActivation(endpointFactory, spec);
    // make sure 2 recovery resources, one is default, one is in activation.
    assertEquals(2, qResourceAdapter.getRecoveryManager().getResources().size());
    qResourceAdapter.stop();
    assertTrue(endpoint.released);
}
Also used : ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) ActiveMQActivationSpec(org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 48 with ActiveMQResourceAdapter

use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.

the class ResourceAdapterTest method testResourceAdapterSetupNoHAOverride.

@Test
public void testResourceAdapterSetupNoHAOverride() throws Exception {
    ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
    qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
    qResourceAdapter.setConnectionParameters("server-id=0");
    qResourceAdapter.setHA(true);
    ActiveMQRATestBase.MyBootstrapContext ctx = new ActiveMQRATestBase.MyBootstrapContext();
    qResourceAdapter.start(ctx);
    ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
    spec.setResourceAdapter(qResourceAdapter);
    spec.setUseJNDI(false);
    spec.setDestinationType("javax.jms.Queue");
    spec.setDestination(MDBQUEUE);
    ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
    assertTrue(fac.isHA());
    qResourceAdapter.stop();
    assertFalse(spec.isHasBeenUpdated());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) ActiveMQActivationSpec(org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec) Test(org.junit.Test)

Example 49 with ActiveMQResourceAdapter

use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.

the class ResourceAdapterTest method testConnectionParameterStringParsing.

@Test
public void testConnectionParameterStringParsing() throws Exception {
    ActiveMQResourceAdapter resourceAdapter = new ActiveMQResourceAdapter();
    resourceAdapter.setConnectionParameters("enabledProtocols=TLS1\\,TLS1.2;sslEnabled=true");
    assertEquals(resourceAdapter.getProperties().getParsedConnectionParameters().get(0).get("enabledProtocols"), "TLS1,TLS1.2");
    resourceAdapter.setConnectionParameters("enabledProtocols=TLS1\\,TLS1.2;sslEnabled=true,enabledProtocols=TLS1.3\\,TLS1.4\\,TLS1.5;sslEnabled=true");
    assertEquals(resourceAdapter.getProperties().getParsedConnectionParameters().get(0).get("enabledProtocols"), "TLS1,TLS1.2");
    assertEquals(resourceAdapter.getProperties().getParsedConnectionParameters().get(1).get("enabledProtocols"), "TLS1.3,TLS1.4,TLS1.5");
    try {
        resourceAdapter.setConnectionParameters("enabledProtocols=TLS1,TLS1.2;sslEnabled=true,enabledProtocols=TLS1,TLS1.2;sslEnabled=true");
        fail("This should have failed");
    } catch (Exception e) {
    // ignore
    }
}
Also used : ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) ResourceException(javax.resource.ResourceException) Test(org.junit.Test)

Example 50 with ActiveMQResourceAdapter

use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.

the class ResourceAdapterTest method testResourceAdapterSetupNoReconnectAttemptsOverride.

@Test
public void testResourceAdapterSetupNoReconnectAttemptsOverride() throws Exception {
    ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
    qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
    qResourceAdapter.setConnectionParameters("server-id=0");
    qResourceAdapter.setReconnectAttempts(100);
    ActiveMQRATestBase.MyBootstrapContext ctx = new ActiveMQRATestBase.MyBootstrapContext();
    qResourceAdapter.start(ctx);
    ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
    spec.setResourceAdapter(qResourceAdapter);
    spec.setUseJNDI(false);
    spec.setDestinationType("javax.jms.Queue");
    spec.setDestination(MDBQUEUE);
    ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
    assertEquals(100, fac.getReconnectAttempts());
    qResourceAdapter.stop();
    assertFalse(spec.isHasBeenUpdated());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) ActiveMQActivationSpec(org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec) Test(org.junit.Test)

Aggregations

ActiveMQResourceAdapter (org.apache.activemq.artemis.ra.ActiveMQResourceAdapter)81 Test (org.junit.Test)72 ActiveMQActivationSpec (org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec)54 CountDownLatch (java.util.concurrent.CountDownLatch)39 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)28 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)24 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)24 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)24 InVMConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory)14 ConnectionFactoryProperties (org.apache.activemq.artemis.ra.ConnectionFactoryProperties)10 ActiveMQRAManagedConnectionFactory (org.apache.activemq.artemis.ra.ActiveMQRAManagedConnectionFactory)9 ActiveMQRAConnectionFactoryImpl (org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactoryImpl)8 Binding (org.apache.activemq.artemis.core.postoffice.Binding)7 HashSet (java.util.HashSet)5 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)5 Role (org.apache.activemq.artemis.core.security.Role)5 ActiveMQActivation (org.apache.activemq.artemis.ra.inflow.ActiveMQActivation)5 Before (org.junit.Before)5 ArrayList (java.util.ArrayList)4 Session (javax.jms.Session)4