use of org.apache.activemq.artemis.core.postoffice.Binding 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();
}
use of org.apache.activemq.artemis.core.postoffice.Binding in project activemq-artemis by apache.
the class JournalPendingMessageTest method getQueues.
protected List<Queue> getQueues(final String address) throws Exception {
final List<Queue> queues = new ArrayList<>();
for (Binding binding : server.getPostOffice().getDirectBindings(SimpleString.toSimpleString(address)).getBindings()) {
if (binding.getType() == BindingType.LOCAL_QUEUE) {
LocalQueueBinding queueBinding = (LocalQueueBinding) binding;
queues.add(queueBinding.getQueue());
}
}
return queues;
}
use of org.apache.activemq.artemis.core.postoffice.Binding in project activemq-artemis by apache.
the class MessageRedistributionTest method getRemoteQueueBinding.
private RemoteQueueBinding getRemoteQueueBinding(ActiveMQServer server) throws Exception {
ActiveMQServer remoteServer = server;
Bindings bindings = remoteServer.getPostOffice().getBindingsForAddress(new SimpleString("queues.testaddress"));
Collection<Binding> bindingSet = bindings.getBindings();
return getRemoteQueueBinding(bindingSet);
}
use of org.apache.activemq.artemis.core.postoffice.Binding in project activemq-artemis by apache.
the class ActiveMQMessageHandlerXATest method testXACommitWhenStopping.
@Test
public void testXACommitWhenStopping() 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);
spec.setMaxSession(1);
qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
CountDownLatch latch = new CountDownLatch(1);
CountDownLatch beforeDeliveryLatch = new CountDownLatch(1);
PausingXADummyEndpoint endpoint = new PausingXADummyEndpoint(latch, beforeDeliveryLatch);
DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, true);
qResourceAdapter.endpointActivation(endpointFactory, spec);
ClientSession session = locator.createSessionFactory().createSession();
ClientProducer clientProducer = session.createProducer(MDBQUEUEPREFIXED);
ClientMessage message = session.createMessage(true);
message.getBodyBuffer().writeString("teststring");
clientProducer.send(message);
ClientMessage message2 = session.createMessage(true);
message2.getBodyBuffer().writeString("teststring2");
clientProducer.send(message2);
session.close();
beforeDeliveryLatch.await(5, TimeUnit.SECONDS);
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
qResourceAdapter.stop();
assertFalse(endpoint.interrupted);
assertNotNull(endpoint.lastMessage);
assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "teststring");
Binding binding = server.getPostOffice().getBinding(MDBQUEUEPREFIXEDSIMPLE);
long messageCount = getMessageCount((Queue) binding.getBindable());
assertEquals(1, messageCount);
}
use of org.apache.activemq.artemis.core.postoffice.Binding in project activemq-artemis by apache.
the class ActiveMQMessageHandlerXATest method testXACommitInterruptsWhenStopping.
@Test
public void testXACommitInterruptsWhenStopping() throws Exception {
ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
qResourceAdapter.start(ctx);
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
spec.setCallTimeout(500L);
spec.setResourceAdapter(qResourceAdapter);
spec.setUseJNDI(false);
spec.setDestinationType("javax.jms.Queue");
spec.setDestination(MDBQUEUE);
spec.setMaxSession(1);
qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
CountDownLatch latch = new CountDownLatch(1);
CountDownLatch beforeDeliveryLatch = new CountDownLatch(1);
PausingXADummyEndpoint endpoint = new PausingXADummyEndpoint(latch, beforeDeliveryLatch);
DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, true);
qResourceAdapter.endpointActivation(endpointFactory, spec);
ClientSession session = locator.createSessionFactory().createSession();
ClientProducer clientProducer = session.createProducer(MDBQUEUEPREFIXED);
ClientMessage message = session.createMessage(true);
message.getBodyBuffer().writeString("teststring");
clientProducer.send(message);
ClientMessage message2 = session.createMessage(true);
message2.getBodyBuffer().writeString("teststring2");
clientProducer.send(message2);
session.close();
beforeDeliveryLatch.await(5, TimeUnit.SECONDS);
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
qResourceAdapter.stop();
assertTrue(endpoint.interrupted);
assertNotNull(endpoint.lastMessage);
assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "teststring");
Binding binding = server.getPostOffice().getBinding(MDBQUEUEPREFIXEDSIMPLE);
Wait.waitFor(() -> getMessageCount((Queue) binding.getBindable()) == 1);
long messageCount = getMessageCount((Queue) binding.getBindable());
assertEquals(1, messageCount);
}
Aggregations