Search in sources :

Example 76 with AddressInfo

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

the class ClientDefinedMultiConsumerTest method test2ConsumersOnSharedDurableAddressReconnectwithNull.

@Test(timeout = 60000)
public void test2ConsumersOnSharedDurableAddressReconnectwithNull() 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.createDurableReceiver(null, "mySub");
    receiver2 = session.createDurableReceiver(null, "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();
}
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 77 with AddressInfo

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

the class ClientDefinedMultiConsumerTest method test2ConsumersOnSharedVolatileAddressBrokerDefined.

@Test(timeout = 60000)
public void test2ConsumersOnSharedVolatileAddressBrokerDefined() throws Exception {
    AddressInfo addressInfo = new AddressInfo(address);
    addressInfo.getRoutingTypes().add(RoutingType.MULTICAST);
    server.addAddressInfo(addressInfo);
    server.createQueue(address, RoutingType.MULTICAST, SimpleString.toSimpleString("myClientId.mySub:shared-volatile"), null, true, false, -1, false, false);
    AmqpClient client = createAmqpClient();
    AmqpConnection connection = addConnection(client.connect("myClientId"));
    AmqpSession session = connection.createSession();
    Source source = createSharedSource(TerminusDurability.NONE);
    AmqpReceiver receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub");
    AmqpReceiver receiver2 = session.createMulticastReceiver(source, "myReceiverID", "mySub|1");
    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:shared-volatile")).getBindable()).getConsumerCount());
    receiver.close();
    assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile")));
    receiver2.close();
    // check its **Hasn't** been deleted
    assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile")));
    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 78 with AddressInfo

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

the class ClientDefinedMultiConsumerTest method test2ConsumersOnNonSharedDurableAddress.

@Test(timeout = 60000)
public void test2ConsumersOnNonSharedDurableAddress() 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 = createNonSharedSource(TerminusDurability.CONFIGURATION);
    Source source1 = createSharedSource(TerminusDurability.CONFIGURATION);
    AmqpReceiver receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub");
    try {
        session.createMulticastReceiver(source1, "myReceiverID", "mySub|2");
        fail("Exception expected");
    } catch (Exception e) {
    // expected
    } finally {
        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) Source(org.apache.qpid.proton.amqp.messaging.Source) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 79 with AddressInfo

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

the class ClientDefinedMultiConsumerTest method test2ConsumersOnSharedVolatileAddressNoReceiverClose.

@Test(timeout = 60000)
public void test2ConsumersOnSharedVolatileAddressNoReceiverClose() 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.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("myClientId.mySub:shared-volatile")).getBindable()).getConsumerCount());
    assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile")));
    // check its been deleted
    connection.close();
    Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisfied() throws Exception {
            return server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile")) == null;
        }
    }, 1000);
}
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) Wait(org.apache.activemq.artemis.tests.util.Wait) 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 80 with AddressInfo

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

the class ClientDefinedMultiConsumerTest method test2ConsumersOnSharedVolatileAddress.

@Test(timeout = 60000)
public void test2ConsumersOnSharedVolatileAddress() 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.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("myClientId.mySub:shared-volatile")).getBindable()).getConsumerCount());
    receiver.close();
    assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile")));
    receiver2.close();
    // check its been deleted
    Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisfied() throws Exception {
            return server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile")) == null;
        }
    }, 1000);
    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) Wait(org.apache.activemq.artemis.tests.util.Wait) 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