use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class ClientDefinedMultiConsumerTest method test2ConsumersOnSharedDurableAddressReconnect.
@Test(timeout = 60000)
public void test2ConsumersOnSharedDurableAddressReconnect() throws Exception {
AddressInfo addressInfo = new AddressInfo(address);
addressInfo.getRoutingTypes().add(RoutingType.MULTICAST);
server.addAddressInfo(addressInfo);
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect("myClientId"));
AmqpSession session = connection.createSession();
Source source = createSharedSource(TerminusDurability.CONFIGURATION);
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("myClientId.mySub")).getBindable()).getConsumerCount());
connection.close();
connection = addConnection(client.connect("myClientId"));
session = connection.createSession();
assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub")));
receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub");
receiver2 = session.createMulticastReceiver(source, "myReceiverID", "mySub|2");
receiver.close();
assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub")));
receiver2.close();
// check its been deleted
assertNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub")));
connection.close();
}
use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class AddressingTest method testMulticastRouting.
@Test
public void testMulticastRouting() throws Exception {
SimpleString sendAddress = new SimpleString("test.address");
List<String> testAddresses = Arrays.asList("test.address", "test.#", "test.*");
for (String consumeAddress : testAddresses) {
// For each address, create 2 Queues with the same address, assert both queues receive message
AddressInfo addressInfo = new AddressInfo(new SimpleString(consumeAddress));
addressInfo.addRoutingType(RoutingType.MULTICAST);
server.addOrUpdateAddressInfo(addressInfo);
Queue q1 = server.createQueue(new SimpleString(consumeAddress), RoutingType.MULTICAST, new SimpleString(consumeAddress + ".1"), null, true, false);
Queue q2 = server.createQueue(new SimpleString(consumeAddress), RoutingType.MULTICAST, new SimpleString(consumeAddress + ".2"), null, true, false);
ClientSession session = sessionFactory.createSession();
session.start();
ClientConsumer consumer1 = session.createConsumer(q1.getName());
ClientConsumer consumer2 = session.createConsumer(q2.getName());
ClientProducer producer = session.createProducer(sendAddress);
ClientMessage m = session.createMessage(ClientMessage.TEXT_TYPE, true);
m.getBodyBuffer().writeString("TestMessage");
producer.send(m);
assertNotNull(consumer1.receive(2000));
assertNotNull(consumer2.receive(2000));
q1.deleteQueue();
q2.deleteQueue();
}
}
use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class AddressingTest method testEmptyRoutingTypes.
@Test
public void testEmptyRoutingTypes() throws Exception {
server.addOrUpdateAddressInfo(new AddressInfo(SimpleString.toSimpleString("xy")));
server.stop();
server.start();
server.addOrUpdateAddressInfo(new AddressInfo(SimpleString.toSimpleString("xy")));
server.stop();
}
use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class AnycastTest method setup.
@Before
public void setup() throws Exception {
server = createServer(true);
server.start();
server.waitForActivation(10, TimeUnit.SECONDS);
ServerLocator sl = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY));
sessionFactory = sl.createSessionFactory();
addSessionFactory(sessionFactory);
addressInfo = new AddressInfo(baseAddress);
addressInfo.addRoutingType(RoutingType.ANYCAST);
server.addOrUpdateAddressInfo(addressInfo);
}
use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class MulticastTest method setup.
@Before
public void setup() throws Exception {
server = createServer(true);
server.start();
server.waitForActivation(10, TimeUnit.SECONDS);
ServerLocator sl = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY));
sessionFactory = sl.createSessionFactory();
addSessionFactory(sessionFactory);
addressInfo = new AddressInfo(baseAddress);
addressInfo.addRoutingType(RoutingType.MULTICAST);
server.addOrUpdateAddressInfo(addressInfo);
}
Aggregations