use of org.apache.activemq.artemis.core.postoffice.QueueBinding in project activemq-artemis by apache.
the class ActiveMQTestBase method waitForBindings.
/**
* @param server the server where's being checked
* @param address the name of the address being checked
* @param local if true we are looking for local bindings, false we are looking for remoting servers
* @param expectedBindingCount the expected number of counts
* @param expectedConsumerCount the expected number of consumers
* @param timeout the timeout used on the check
* @return
* @throws Exception
* @throws InterruptedException
*/
protected boolean waitForBindings(final ActiveMQServer server, final String address, final boolean local, final int expectedBindingCount, final int expectedConsumerCount, long timeout) throws Exception {
final PostOffice po = server.getPostOffice();
long start = System.currentTimeMillis();
int bindingCount = 0;
int totConsumers = 0;
do {
bindingCount = 0;
totConsumers = 0;
Bindings bindings = po.getBindingsForAddress(new SimpleString(address));
for (Binding binding : bindings.getBindings()) {
if (binding.isConnected() && (binding instanceof LocalQueueBinding && local || binding instanceof RemoteQueueBinding && !local)) {
QueueBinding qBinding = (QueueBinding) binding;
bindingCount++;
totConsumers += qBinding.consumerCount();
}
}
if (bindingCount == expectedBindingCount && totConsumers == expectedConsumerCount) {
return true;
}
Thread.sleep(10);
} while (System.currentTimeMillis() - start < timeout);
String msg = "Timed out waiting for bindings (bindingCount = " + bindingCount + " (expecting " + expectedBindingCount + ") " + ", totConsumers = " + totConsumers + " (expecting " + expectedConsumerCount + ")" + ")";
log.error(msg);
return false;
}
use of org.apache.activemq.artemis.core.postoffice.QueueBinding in project activemq-artemis by apache.
the class ActiveMQTestBase method getLocalQueueBindings.
private List<QueueBinding> getLocalQueueBindings(final PostOffice postOffice, final String address) throws Exception {
ArrayList<QueueBinding> bindingsFound = new ArrayList<>();
Bindings bindings = postOffice.getBindingsForAddress(new SimpleString(address));
for (Binding binding : bindings.getBindings()) {
if (binding instanceof LocalQueueBinding) {
bindingsFound.add((QueueBinding) binding);
}
}
return bindingsFound;
}
use of org.apache.activemq.artemis.core.postoffice.QueueBinding in project activemq-artemis by apache.
the class QueueConfigRestartTest method testQueueConfigExclusiveAndRestart.
@Test
public void testQueueConfigExclusiveAndRestart() throws Exception {
ActiveMQServer server = createServer(true);
server.start();
SimpleString address = new SimpleString("test.address");
SimpleString queue = new SimpleString("test.queue");
server.createQueue(address, RoutingType.MULTICAST, queue, null, null, true, false, false, false, false, 10, true, true, true, true);
QueueBinding queueBinding1 = (QueueBinding) server.getPostOffice().getBinding(queue);
Assert.assertTrue(queueBinding1.getQueue().isExclusive());
server.stop();
server.start();
QueueBinding queueBinding2 = (QueueBinding) server.getPostOffice().getBinding(queue);
Assert.assertTrue(queueBinding2.getQueue().isExclusive());
}
use of org.apache.activemq.artemis.core.postoffice.QueueBinding in project activemq-artemis by apache.
the class QueueConfigRestartTest method testQueueConfigUserAndRestart.
@Test
public void testQueueConfigUserAndRestart() throws Exception {
ActiveMQServer server = createServer(true);
server.start();
SimpleString address = new SimpleString("test.address");
SimpleString queue = new SimpleString("test.queue");
server.createQueue(address, RoutingType.MULTICAST, queue, null, SimpleString.toSimpleString("bob"), true, false, false, 10, true, true);
QueueBinding queueBinding1 = (QueueBinding) server.getPostOffice().getBinding(queue);
Assert.assertEquals(SimpleString.toSimpleString("bob"), queueBinding1.getQueue().getUser());
server.stop();
server.start();
QueueBinding queueBinding2 = (QueueBinding) server.getPostOffice().getBinding(queue);
Assert.assertTrue(queueBinding2.getQueue().isPurgeOnNoConsumers());
}
use of org.apache.activemq.artemis.core.postoffice.QueueBinding in project activemq-artemis by apache.
the class PostOfficeImpl method listQueuesForAddress.
@Override
public List<Queue> listQueuesForAddress(SimpleString address) throws Exception {
Bindings bindingsForAddress = getBindingsForAddress(address);
List<Queue> queues = new ArrayList<>();
for (Binding b : bindingsForAddress.getBindings()) {
if (b instanceof QueueBinding) {
Queue q = ((QueueBinding) b).getQueue();
queues.add(q);
}
}
return queues;
}
Aggregations