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