use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.
the class ActiveMQMessageHandlerTest method testMaxSessions.
@Test
public void testMaxSessions() throws Exception {
ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
qResourceAdapter.start(ctx);
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
spec.setMaxSession(1);
spec.setResourceAdapter(qResourceAdapter);
spec.setUseJNDI(false);
spec.setDestinationType("javax.jms.Queue");
spec.setDestination(MDBQUEUE);
qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
CountDownLatch latch = new CountDownLatch(1);
DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
qResourceAdapter.endpointActivation(endpointFactory, spec);
Binding binding = server.getPostOffice().getBinding(MDBQUEUEPREFIXEDSIMPLE);
assertEquals(((LocalQueueBinding) binding).getQueue().getConsumerCount(), 1);
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
qResourceAdapter.stop();
}
use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.
the class ActiveMQMessageHandlerTest method testNonDurableSubscription.
@Test
public void testNonDurableSubscription() throws Exception {
ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
qResourceAdapter.start(ctx);
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
spec.setResourceAdapter(qResourceAdapter);
spec.setUseJNDI(false);
spec.setDestinationType("javax.jms.Topic");
spec.setDestination("mdbTopic");
qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
CountDownLatch latch = new CountDownLatch(1);
DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
qResourceAdapter.endpointActivation(endpointFactory, spec);
ClientSession session = locator.createSessionFactory().createSession();
ClientProducer clientProducer = session.createProducer("mdbTopic");
ClientMessage message = session.createMessage(true);
message.getBodyBuffer().writeString("1");
clientProducer.send(message);
latch.await(5, TimeUnit.SECONDS);
assertNotNull(endpoint.lastMessage);
assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "1");
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
message = session.createMessage(true);
message.getBodyBuffer().writeString("2");
clientProducer.send(message);
latch = new CountDownLatch(1);
endpoint = new DummyMessageEndpoint(latch);
endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
qResourceAdapter.endpointActivation(endpointFactory, spec);
message = session.createMessage(true);
message.getBodyBuffer().writeString("3");
clientProducer.send(message);
latch.await(5, TimeUnit.SECONDS);
assertNotNull(endpoint.lastMessage);
assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "3");
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
qResourceAdapter.stop();
}
use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.
the class ActiveMQMessageHandlerTest method newResourceAdapter.
/**
* @return
*/
@Override
protected ActiveMQResourceAdapter newResourceAdapter() {
ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
return qResourceAdapter;
}
use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.
the class ActiveMQMessageHandlerTest method testSimpleMessageReceivedOnQueueManyMessages.
@Test
public void testSimpleMessageReceivedOnQueueManyMessages() throws Exception {
ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
qResourceAdapter.start(ctx);
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
spec.setResourceAdapter(qResourceAdapter);
spec.setUseJNDI(false);
spec.setDestinationType("javax.jms.Queue");
spec.setDestination(MDBQUEUE);
qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
CountDownLatch latch = new CountDownLatch(15);
MultipleEndpoints endpoint = new MultipleEndpoints(latch, null, false);
DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
qResourceAdapter.endpointActivation(endpointFactory, spec);
ClientSession session = locator.createSessionFactory().createSession();
ClientProducer clientProducer = session.createProducer(MDBQUEUEPREFIXED);
for (int i = 0; i < 15; i++) {
ClientMessage message = session.createMessage(true);
message.getBodyBuffer().writeString("teststring" + i);
clientProducer.send(message);
}
session.close();
latch.await(5, TimeUnit.SECONDS);
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
qResourceAdapter.stop();
}
use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.
the class ActiveMQMessageHandlerTest method testEndpointDeactivated.
@Test
public void testEndpointDeactivated() throws Exception {
ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
qResourceAdapter.start(ctx);
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
spec.setResourceAdapter(qResourceAdapter);
spec.setUseJNDI(false);
spec.setDestinationType("javax.jms.Queue");
spec.setDestination(MDBQUEUE);
qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
CountDownLatch latch = new CountDownLatch(1);
DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
qResourceAdapter.endpointActivation(endpointFactory, spec);
Binding binding = server.getPostOffice().getBinding(MDBQUEUEPREFIXEDSIMPLE);
assertEquals(((LocalQueueBinding) binding).getQueue().getConsumerCount(), 15);
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
assertEquals(((LocalQueueBinding) binding).getQueue().getConsumerCount(), 0);
assertTrue(endpoint.released);
qResourceAdapter.stop();
}
Aggregations