Search in sources :

Example 46 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class BrokerDefinedAnycastConsumerTest method testConsumeFromSingleQueueOnAddressDifferentNameMultipleQueues.

@Test(timeout = 60000)
public void testConsumeFromSingleQueueOnAddressDifferentNameMultipleQueues() throws Exception {
    server.addAddressInfo(new AddressInfo(address, RoutingType.ANYCAST));
    server.createQueue(address, RoutingType.ANYCAST, queue1, null, true, false);
    server.createQueue(address, RoutingType.ANYCAST, queue2, 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());
    assertEquals(0, ((QueueImpl) server.getPostOffice().getBinding(queue2).getBindable()).getConsumerCount());
    receiver.close();
    connection.close();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) AmqpMessage(org.apache.activemq.transport.amqp.client.AmqpMessage) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 47 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class BrokerDefinedAnycastConsumerTest method testConsumeFromSingleQueueOnAddressSameName.

@Test(timeout = 60000)
public void testConsumeFromSingleQueueOnAddressSameName() throws Exception {
    server.addAddressInfo(new AddressInfo(address, RoutingType.ANYCAST));
    server.createQueue(address, RoutingType.ANYCAST, address, 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(address).getBindable()).getConsumerCount());
    receiver.close();
    connection.close();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) AmqpMessage(org.apache.activemq.transport.amqp.client.AmqpMessage) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 48 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class BrokerDefinedMulticastConsumerTest method testConsumeFromSingleQueueOnAddressSameName.

@Test(timeout = 60000)
public void testConsumeFromSingleQueueOnAddressSameName() throws Exception {
    server.addAddressInfo(new AddressInfo(address, RoutingType.MULTICAST));
    server.createQueue(address, RoutingType.MULTICAST, address, 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() + "::" + address.toString());
    receiver.flow(1);
    AmqpMessage amqpMessage = receiver.receive(5, TimeUnit.SECONDS);
    assertNotNull(amqpMessage);
    assertEquals(1, ((QueueImpl) server.getPostOffice().getBinding(address).getBindable()).getConsumerCount());
    receiver.close();
    connection.close();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) AmqpMessage(org.apache.activemq.transport.amqp.client.AmqpMessage) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 49 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class ClientDefinedMultiConsumerTest method test2ConsumersOnSharedDurableAddressGlobal.

@Test(timeout = 60000)
public void test2ConsumersOnSharedDurableAddressGlobal() 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.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("mySub:global")).getBindable()).getConsumerCount());
    receiver.close();
    assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("mySub:global")));
    receiver2.close();
    // check its been deleted
    assertNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("mySub:global")));
    connection.close();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) Source(org.apache.qpid.proton.amqp.messaging.Source) AmqpMessage(org.apache.activemq.transport.amqp.client.AmqpMessage) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 50 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class ClientDefinedMultiConsumerTest method test2ConsumersOnSharedDurableAddress.

@Test(timeout = 60000)
public void test2ConsumersOnSharedDurableAddress() 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());
    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();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) Source(org.apache.qpid.proton.amqp.messaging.Source) AmqpMessage(org.apache.activemq.transport.amqp.client.AmqpMessage) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Aggregations

AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)116 Test (org.junit.Test)89 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)73 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)32 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)24 AmqpConnection (org.apache.activemq.transport.amqp.client.AmqpConnection)23 AmqpSession (org.apache.activemq.transport.amqp.client.AmqpSession)23 AmqpClient (org.apache.activemq.transport.amqp.client.AmqpClient)22 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)21 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)19 AmqpMessage (org.apache.activemq.transport.amqp.client.AmqpMessage)18 AmqpReceiver (org.apache.activemq.transport.amqp.client.AmqpReceiver)17 JsonObject (javax.json.JsonObject)16 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)16 ActiveMQServerControl (org.apache.activemq.artemis.api.core.management.ActiveMQServerControl)16 JsonArray (javax.json.JsonArray)15 Queue (org.apache.activemq.artemis.core.server.Queue)15 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)13 Configuration (org.apache.activemq.artemis.core.config.Configuration)12 Session (javax.jms.Session)11