use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class AmqpSendReceiveTest method testSendingAndReceivingToQueueWithDifferentAddressAndQueueName.
@Test(timeout = 60000)
public void testSendingAndReceivingToQueueWithDifferentAddressAndQueueName() throws Exception {
String queueName = "TestQueueName";
String address = "TestAddress";
server.addAddressInfo(new AddressInfo(SimpleString.toSimpleString(address), RoutingType.ANYCAST));
server.createQueue(new SimpleString(address), RoutingType.ANYCAST, new SimpleString(queueName), null, true, false);
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
try {
AmqpSession session = connection.createSession();
AmqpSender sender = session.createSender(address);
AmqpReceiver receiver = session.createReceiver(address);
receiver.flow(1);
AmqpMessage message = new AmqpMessage();
message.setText("TestPayload");
sender.send(message);
AmqpMessage receivedMessage = receiver.receive(5000, TimeUnit.MILLISECONDS);
assertNotNull(receivedMessage);
} finally {
connection.close();
}
}
use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class BrokerDefinedAnycastConsumerTest method testConsumeWhenOnlyMulticast.
@Test(timeout = 60000)
public void testConsumeWhenOnlyMulticast() throws Exception {
server.addAddressInfo(new AddressInfo(address, RoutingType.MULTICAST));
sendMessages(address.toString(), 1);
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
Source jmsSource = createJmsSource(false);
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 BrokerDefinedAnycastConsumerTest method testConsumeWhenNoAddressHasBothRoutingTypesButDefaultQueueIsMultiCast.
@Test(timeout = 60000)
public void testConsumeWhenNoAddressHasBothRoutingTypesButDefaultQueueIsMultiCast() throws Exception {
AddressInfo addressInfo = new AddressInfo(address);
addressInfo.getRoutingTypes().add(RoutingType.ANYCAST);
addressInfo.getRoutingTypes().add(RoutingType.MULTICAST);
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 AmqpMessageRoutingTest method testRoutingExclusivity.
/**
* If we have an address configured with both ANYCAST and MULTICAST routing types enabled, we must ensure that any
* messages sent specifically to MULTICAST (e.g. JMS TopicProducer) are only delivered to MULTICAST queues (e.g.
* i.e. subscription queues) and **NOT** to ANYCAST queues (e.g. JMS Queue).
*
* @throws Exception
*/
@Test(timeout = 60000)
public void testRoutingExclusivity() throws Exception {
// Create Address with both ANYCAST and MULTICAST enabled
String testAddress = "testRoutingExclusivity-mixed-mode";
SimpleString ssTestAddress = new SimpleString(testAddress);
AddressInfo addressInfo = new AddressInfo(ssTestAddress);
addressInfo.addRoutingType(RoutingType.MULTICAST);
addressInfo.addRoutingType(RoutingType.ANYCAST);
server.addAddressInfo(addressInfo);
server.createQueue(ssTestAddress, RoutingType.ANYCAST, ssTestAddress, null, true, false);
Connection connection = createConnection(UUIDGenerator.getInstance().generateStringUUID());
try {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = session.createTopic(testAddress);
javax.jms.Queue queue = session.createQueue(testAddress);
MessageProducer producer = session.createProducer(topic);
MessageConsumer queueConsumer = session.createConsumer(queue);
MessageConsumer topicConsumer = session.createConsumer(topic);
producer.send(session.createTextMessage("testMessage"));
assertNotNull(topicConsumer.receive(1000));
assertNull(queueConsumer.receive(1000));
} finally {
connection.close();
}
}
use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class BrokerDefinedAnycastConsumerTest method testConsumeFromSingleQueueOnAddressSameNameMultipleQueues.
@Test(timeout = 60000)
public void testConsumeFromSingleQueueOnAddressSameNameMultipleQueues() throws Exception {
server.addAddressInfo(new AddressInfo(address, RoutingType.ANYCAST));
server.createQueue(address, RoutingType.ANYCAST, queue1, null, true, false);
server.createQueue(address, RoutingType.ANYCAST, address, null, true, false);
sendMessages(address.toString(), 2);
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(address).getBindable()).getConsumerCount());
assertEquals(0, ((QueueImpl) server.getPostOffice().getBinding(queue1).getBindable()).getConsumerCount());
receiver.close();
connection.close();
}
Aggregations