use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class BrokerDefinedAnycastConsumerTest method testConsumeFromSingleQueueOnAddressDifferentName.
@Test(timeout = 60000)
public void testConsumeFromSingleQueueOnAddressDifferentName() throws Exception {
server.addAddressInfo(new AddressInfo(address, RoutingType.ANYCAST));
server.createQueue(address, RoutingType.ANYCAST, queue1, null, true, false);
sendMessages(address.toString(), 1);
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
AmqpReceiver receiver = session.createReceiver(address.toString());
receiver.flow(1);
AmqpMessage amqpMessage = receiver.receive(5, TimeUnit.SECONDS);
assertNotNull(amqpMessage);
assertEquals(1, ((QueueImpl) server.getPostOffice().getBinding(queue1).getBindable()).getConsumerCount());
receiver.close();
connection.close();
}
use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class BrokerDefinedAnycastConsumerTest method testConsumeFromSingleQualifiedQueueOnAddressSameName.
@Test(timeout = 60000)
public void testConsumeFromSingleQualifiedQueueOnAddressSameName() throws Exception {
server.addAddressInfo(new AddressInfo(address, RoutingType.ANYCAST));
server.createQueue(address, RoutingType.ANYCAST, queue1, null, true, false);
sendMessages(address.toString(), 1);
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
AmqpReceiver receiver = session.createReceiver(address.toString() + "::" + queue1.toString());
receiver.flow(1);
AmqpMessage amqpMessage = receiver.receive(5, TimeUnit.SECONDS);
assertNotNull(amqpMessage);
assertEquals(1, ((QueueImpl) server.getPostOffice().getBinding(queue1).getBindable()).getConsumerCount());
receiver.close();
connection.close();
}
use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class BrokerDefinedMulticastConsumerTest method testConsumeWhenNoAddressHasBothRoutingTypesButDefaultQueueIsAnyCast.
@Test(timeout = 60000)
public void testConsumeWhenNoAddressHasBothRoutingTypesButDefaultQueueIsAnyCast() throws Exception {
AddressInfo addressInfo = new AddressInfo(address);
addressInfo.getRoutingTypes().add(RoutingType.MULTICAST);
addressInfo.getRoutingTypes().add(RoutingType.ANYCAST);
server.addAddressInfo(addressInfo);
server.createQueue(address, RoutingType.MULTICAST, address, null, true, false);
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
try {
session.createReceiver(address.toString());
fail("expected exception");
} catch (Exception e) {
// ignore
}
connection.close();
}
use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class BrokerDefinedMulticastConsumerTest method testConsumeWhenOnlyAnycast.
@Test(timeout = 60000)
public void testConsumeWhenOnlyAnycast() throws Exception {
server.addAddressInfo(new AddressInfo(address, RoutingType.ANYCAST));
sendMessages(address.toString(), 1);
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
Source jmsSource = createJmsSource(true);
jmsSource.setAddress(address.toString());
try {
session.createReceiver(jmsSource);
fail("should throw exception");
} catch (Exception e) {
// ignore
}
connection.close();
}
use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class ClientDefinedMultiConsumerTest method test2ConsumersOnSharedVolatileAddressGlobal.
@Test(timeout = 60000)
public void test2ConsumersOnSharedVolatileAddressGlobal() throws Exception {
AddressInfo addressInfo = new AddressInfo(address);
addressInfo.getRoutingTypes().add(RoutingType.MULTICAST);
server.addAddressInfo(addressInfo);
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect(false));
AmqpSession session = connection.createSession();
Source source = createSharedGlobalSource(TerminusDurability.NONE);
AmqpReceiver receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub");
AmqpReceiver receiver2 = session.createMulticastReceiver(source, "myReceiverID", "mySub|2");
receiver.flow(1);
receiver2.flow(1);
sendMessages(address.toString(), 2);
AmqpMessage amqpMessage = receiver.receive(5, TimeUnit.SECONDS);
assertNotNull(amqpMessage);
amqpMessage = receiver2.receive(5, TimeUnit.SECONDS);
assertNotNull(amqpMessage);
assertEquals(2, ((QueueImpl) server.getPostOffice().getBinding(SimpleString.toSimpleString("mySub:shared-volatile:global")).getBindable()).getConsumerCount());
receiver.close();
assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("mySub:shared-volatile:global")));
receiver2.close();
// check its been deleted
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisfied() throws Exception {
return server.getPostOffice().getBinding(SimpleString.toSimpleString("mySub:shared-volatile:global")) == null;
}
}, 1000);
connection.close();
}
Aggregations