Search in sources :

Example 31 with Binding

use of org.apache.activemq.artemis.core.postoffice.Binding in project activemq-artemis by apache.

the class MQTTFQQNTest method testMQTTSubNames.

@Test
public void testMQTTSubNames() throws Exception {
    final MQTTClientProvider subscriptionProvider = getMQTTClientProvider();
    initializeConnection(subscriptionProvider);
    try {
        subscriptionProvider.subscribe("foo/bah", AT_MOST_ONCE);
        Map<SimpleString, Binding> allBindings = server.getPostOffice().getAllBindings();
        assertEquals(1, allBindings.size());
        Binding b = allBindings.values().iterator().next();
        // check that query using bare queue name works as before
        QueueQueryResult result = server.queueQuery(b.getUniqueName());
        assertTrue(result.isExists());
        assertEquals(result.getAddress(), new SimpleString("foo.bah"));
        assertEquals(b.getUniqueName(), result.getName());
        // check that queue query using FQQN returns FQQN
        result = server.queueQuery(new SimpleString("foo.bah::" + b.getUniqueName()));
        assertTrue(result.isExists());
        assertEquals(new SimpleString("foo.bah"), result.getAddress());
        assertEquals(new SimpleString("foo.bah::" + b.getUniqueName()), result.getName());
    } finally {
        subscriptionProvider.disconnect();
    }
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) QueueQueryResult(org.apache.activemq.artemis.core.server.QueueQueryResult) Test(org.junit.Test)

Example 32 with Binding

use of org.apache.activemq.artemis.core.postoffice.Binding in project activemq-artemis by apache.

the class MQTTFQQNTest method testMQTTSubNamesSpecial.

@Test
public void testMQTTSubNamesSpecial() throws Exception {
    final MQTTClientProvider subscriptionProvider = getMQTTClientProvider();
    initializeConnection(subscriptionProvider);
    try {
        subscriptionProvider.subscribe("foo/bah", AT_MOST_ONCE);
        Map<SimpleString, Binding> allBindings = server.getPostOffice().getAllBindings();
        assertEquals(1, allBindings.size());
        Binding b = allBindings.values().iterator().next();
        // check ::queue
        QueueQueryResult result = server.queueQuery(new SimpleString("::" + b.getUniqueName()));
        assertTrue(result.isExists());
        assertEquals(new SimpleString("foo.bah"), result.getAddress());
        assertEquals(new SimpleString("::" + b.getUniqueName()), result.getName());
        // check queue::
        result = server.queueQuery(new SimpleString(b.getUniqueName() + "::"));
        assertFalse(result.isExists());
        // check ::
        result = server.queueQuery(new SimpleString("::"));
        assertFalse(result.isExists());
    } finally {
        subscriptionProvider.disconnect();
    }
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) QueueQueryResult(org.apache.activemq.artemis.core.server.QueueQueryResult) Test(org.junit.Test)

Example 33 with Binding

use of org.apache.activemq.artemis.core.postoffice.Binding in project activemq-artemis by apache.

the class ClusterTestBase method waitForBindings.

protected void waitForBindings(final int node, final String address, final int expectedBindingCount, final int expectedConsumerCount, final boolean local) throws Exception {
    log.debug("waiting for bindings on node " + node + " address " + address + " expectedBindingCount " + expectedBindingCount + " consumerCount " + expectedConsumerCount + " local " + local);
    ActiveMQServer server = servers[node];
    if (server == null) {
        throw new IllegalArgumentException("No server at " + node);
    }
    long timeout = ActiveMQTestBase.WAIT_TIMEOUT;
    if (waitForBindings(server, address, local, expectedBindingCount, expectedConsumerCount, timeout)) {
        return;
    }
    PostOffice po = server.getPostOffice();
    Bindings bindings = po.getBindingsForAddress(new SimpleString(address));
    System.out.println("=======================================================================");
    System.out.println("Binding information for address = " + address + " on node " + node);
    for (Binding binding : bindings.getBindings()) {
        if (binding.isConnected() && (binding instanceof LocalQueueBinding && local || binding instanceof RemoteQueueBinding && !local)) {
            QueueBinding qBinding = (QueueBinding) binding;
            System.out.println("Binding = " + qBinding + ", queue=" + qBinding.getQueue());
        }
    }
    StringWriter writer = new StringWriter();
    PrintWriter out = new PrintWriter(writer);
    try {
        for (ActiveMQServer activeMQServer : servers) {
            if (activeMQServer != null) {
                out.println(clusterDescription(activeMQServer));
                out.println(debugBindings(activeMQServer, activeMQServer.getConfiguration().getManagementNotificationAddress().toString()));
            }
        }
        for (ActiveMQServer activeMQServer : servers) {
            out.println("Management bindings on " + activeMQServer);
            if (activeMQServer != null) {
                out.println(debugBindings(activeMQServer, activeMQServer.getConfiguration().getManagementNotificationAddress().toString()));
            }
        }
    } catch (Throwable dontCare) {
    }
    logAndSystemOut(writer.toString());
    throw new IllegalStateException("Didn't get the expected number of bindings, look at the logging for more information");
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) LocalQueueBinding(org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) RemoteQueueBinding(org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding) LocalQueueBinding(org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) RemoteQueueBinding(org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding) PostOffice(org.apache.activemq.artemis.core.postoffice.PostOffice) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Bindings(org.apache.activemq.artemis.core.postoffice.Bindings) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) LocalQueueBinding(org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding) StringWriter(java.io.StringWriter) RemoteQueueBinding(org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding) PrintWriter(java.io.PrintWriter)

Example 34 with Binding

use of org.apache.activemq.artemis.core.postoffice.Binding in project activemq-artemis by apache.

the class ClusterTestBase method debugBindings.

protected String debugBindings(final ActiveMQServer server, final String address) throws Exception {
    StringWriter str = new StringWriter();
    PrintWriter out = new PrintWriter(str);
    if (server == null) {
        return "server is shutdown";
    }
    PostOffice po = server.getPostOffice();
    if (po == null) {
        return "server is shutdown";
    }
    Bindings bindings = po.getBindingsForAddress(new SimpleString(address));
    out.println("=======================================================================");
    out.println("Binding information for address = " + address + " on " + server);
    for (Binding binding : bindings.getBindings()) {
        QueueBinding qBinding = (QueueBinding) binding;
        out.println("Binding = " + qBinding + ", queue=" + qBinding.getQueue());
    }
    out.println("=======================================================================");
    return str.toString();
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) LocalQueueBinding(org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) RemoteQueueBinding(org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding) LocalQueueBinding(org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) RemoteQueueBinding(org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding) StringWriter(java.io.StringWriter) PostOffice(org.apache.activemq.artemis.core.postoffice.PostOffice) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Bindings(org.apache.activemq.artemis.core.postoffice.Bindings) PrintWriter(java.io.PrintWriter)

Example 35 with Binding

use of org.apache.activemq.artemis.core.postoffice.Binding in project activemq-artemis by apache.

the class SessionCreateAndDeleteQueueTest method testDeleteQueue.

@Test
public void testDeleteQueue() throws Exception {
    ClientSession session = createSessionFactory(locator).createSession(false, true, true);
    session.createQueue(address, queueName, false);
    Binding binding = server.getPostOffice().getBinding(queueName);
    Assert.assertNotNull(binding);
    session.deleteQueue(queueName);
    binding = server.getPostOffice().getBinding(queueName);
    Assert.assertNull(binding);
    session.close();
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) Test(org.junit.Test)

Aggregations

Binding (org.apache.activemq.artemis.core.postoffice.Binding)81 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)52 LocalQueueBinding (org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding)29 QueueBinding (org.apache.activemq.artemis.core.postoffice.QueueBinding)28 Test (org.junit.Test)25 Bindings (org.apache.activemq.artemis.core.postoffice.Bindings)24 Queue (org.apache.activemq.artemis.core.server.Queue)24 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)18 RemoteQueueBinding (org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding)17 ArrayList (java.util.ArrayList)12 Filter (org.apache.activemq.artemis.core.filter.Filter)10 DivertBinding (org.apache.activemq.artemis.core.postoffice.impl.DivertBinding)10 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)9 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)9 Map (java.util.Map)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 QueueQueryResult (org.apache.activemq.artemis.core.server.QueueQueryResult)8 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)7 PostOffice (org.apache.activemq.artemis.core.postoffice.PostOffice)7 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)7