Search in sources :

Example 1 with Bindable

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

the class MessageRedistributionTest method testRedistributionStopsWhenConsumerAdded.

// https://issues.jboss.org/browse/HORNETQ-1057
@Test
public void testRedistributionStopsWhenConsumerAdded() throws Exception {
    setupCluster(MessageLoadBalancingType.ON_DEMAND);
    MessageRedistributionTest.log.info("Doing test");
    startServers(0, 1, 2);
    setupSessionFactory(0, isNetty());
    setupSessionFactory(1, isNetty());
    setupSessionFactory(2, isNetty());
    createQueue(0, "queues.testaddress", "queue0", null, false);
    createQueue(1, "queues.testaddress", "queue0", null, false);
    createQueue(2, "queues.testaddress", "queue0", null, false);
    addConsumer(0, 0, "queue0", null);
    waitForBindings(0, "queues.testaddress", 1, 1, true);
    waitForBindings(1, "queues.testaddress", 1, 0, true);
    waitForBindings(2, "queues.testaddress", 1, 0, true);
    waitForBindings(0, "queues.testaddress", 2, 0, false);
    waitForBindings(1, "queues.testaddress", 2, 1, false);
    waitForBindings(2, "queues.testaddress", 2, 1, false);
    send(0, "queues.testaddress", 2000, false, null);
    removeConsumer(0);
    addConsumer(0, 0, "queue0", null);
    Bindable bindable = servers[0].getPostOffice().getBinding(new SimpleString("queue0")).getBindable();
    String debug = ((QueueImpl) bindable).debug();
    Assert.assertFalse(debug.contains(Redistributor.class.getName()));
    MessageRedistributionTest.log.info("Test done");
}
Also used : Bindable(org.apache.activemq.artemis.core.server.Bindable) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) QueueImpl(org.apache.activemq.artemis.core.server.impl.QueueImpl) Test(org.junit.Test)

Example 2 with Bindable

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

the class ActiveMQServerImpl method locateQueue.

@Override
public Queue locateQueue(SimpleString queueName) {
    Binding binding = postOffice.getBinding(queueName);
    if (binding == null) {
        return null;
    }
    Bindable queue = binding.getBindable();
    if (!(queue instanceof Queue)) {
        throw new IllegalStateException("locateQueue should only be used to locate queues");
    }
    return (Queue) binding.getBindable();
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) DivertBinding(org.apache.activemq.artemis.core.postoffice.impl.DivertBinding) LocalQueueBinding(org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) Bindable(org.apache.activemq.artemis.core.server.Bindable) SynchronousQueue(java.util.concurrent.SynchronousQueue) Queue(org.apache.activemq.artemis.core.server.Queue)

Aggregations

Bindable (org.apache.activemq.artemis.core.server.Bindable)2 SynchronousQueue (java.util.concurrent.SynchronousQueue)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 Binding (org.apache.activemq.artemis.core.postoffice.Binding)1 QueueBinding (org.apache.activemq.artemis.core.postoffice.QueueBinding)1 DivertBinding (org.apache.activemq.artemis.core.postoffice.impl.DivertBinding)1 LocalQueueBinding (org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding)1 Queue (org.apache.activemq.artemis.core.server.Queue)1 QueueImpl (org.apache.activemq.artemis.core.server.impl.QueueImpl)1 Test (org.junit.Test)1