Search in sources :

Example 61 with Binding

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

the class AddressControlImpl method getBindingNames.

@Override
public String[] getBindingNames() throws Exception {
    clearIO();
    try {
        Bindings bindings = postOffice.getBindingsForAddress(addressInfo.getName());
        String[] bindingNames = new String[bindings.getBindings().size()];
        int i = 0;
        for (Binding binding : bindings.getBindings()) {
            bindingNames[i++] = binding.getUniqueName().toString();
        }
        return bindingNames;
    } catch (Throwable t) {
        throw new IllegalStateException(t.getMessage());
    } finally {
        blockOnIO();
    }
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Bindings(org.apache.activemq.artemis.core.postoffice.Bindings)

Example 62 with Binding

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

the class AddressControlImpl method getNumberOfMessages.

@Override
public long getNumberOfMessages() throws Exception {
    clearIO();
    long totalMsgs = 0;
    try {
        Bindings bindings = postOffice.getBindingsForAddress(addressInfo.getName());
        for (Binding binding : bindings.getBindings()) {
            if (binding instanceof QueueBinding) {
                totalMsgs += ((QueueBinding) binding).getQueue().getMessageCount();
            }
        }
        return totalMsgs;
    } catch (Throwable t) {
        throw new IllegalStateException(t.getMessage());
    } finally {
        blockOnIO();
    }
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) Bindings(org.apache.activemq.artemis.core.postoffice.Bindings)

Example 63 with Binding

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

the class QueueControlImpl method moveMessage.

@Override
public boolean moveMessage(final long messageID, final String otherQueueName, final boolean rejectDuplicates) throws Exception {
    checkStarted();
    clearIO();
    try {
        Binding binding = postOffice.getBinding(new SimpleString(otherQueueName));
        if (binding == null) {
            throw ActiveMQMessageBundle.BUNDLE.noQueueFound(otherQueueName);
        }
        return queue.moveReference(messageID, binding.getAddress(), binding, rejectDuplicates);
    } finally {
        blockOnIO();
    }
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 64 with Binding

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

the class SessionCreateAndDeleteQueueTest method testDurableTrue.

@Test
public void testDurableTrue() throws Exception {
    ClientSession session = createSessionFactory(locator).createSession(false, true, true);
    session.createQueue(address, queueName, true);
    Binding binding = server.getPostOffice().getBinding(queueName);
    Queue q = (Queue) binding.getBindable();
    Assert.assertTrue(q.isDurable());
    session.close();
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) Queue(org.apache.activemq.artemis.core.server.Queue) LastValueQueue(org.apache.activemq.artemis.core.server.impl.LastValueQueue) Test(org.junit.Test)

Example 65 with Binding

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

the class SessionCreateAndDeleteQueueTest method testTemporaryFalse.

@Test
public void testTemporaryFalse() throws Exception {
    ClientSession session = createSessionFactory(locator).createSession(false, true, true);
    session.createQueue(address, queueName, false);
    Binding binding = server.getPostOffice().getBinding(queueName);
    Queue q = (Queue) binding.getBindable();
    Assert.assertFalse(q.isTemporary());
    session.close();
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) Queue(org.apache.activemq.artemis.core.server.Queue) LastValueQueue(org.apache.activemq.artemis.core.server.impl.LastValueQueue) 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