use of org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding 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.impl.LocalQueueBinding 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.impl.LocalQueueBinding in project activemq-artemis by apache.
the class ActiveMQMessageHandlerSecurityTest method testSimpleMessageReceivedOnQueueWithSecurityFails.
@Test
public void testSimpleMessageReceivedOnQueueWithSecurityFails() throws Exception {
SecurityConfiguration emptyConfiguration = new SecurityConfiguration();
((ActiveMQJAASSecurityManager) server.getSecurityManager()).setConfiguration(emptyConfiguration);
ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
qResourceAdapter.start(ctx);
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
spec.setResourceAdapter(qResourceAdapter);
spec.setUseJNDI(false);
spec.setDestinationType("javax.jms.Queue");
spec.setDestination(MDBQUEUE);
spec.setUser("dodgyuser");
spec.setPassword("dodgypassword");
spec.setSetupAttempts(0);
qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
CountDownLatch latch = new CountDownLatch(1);
DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
qResourceAdapter.endpointActivation(endpointFactory, spec);
Binding binding = server.getPostOffice().getBinding(MDBQUEUEPREFIXEDSIMPLE);
assertEquals(0, ((LocalQueueBinding) binding).getQueue().getConsumerCount());
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
qResourceAdapter.stop();
}
use of org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding in project activemq-artemis by apache.
the class ActiveMQMessageHandlerTest method testMaxSessions.
@Test
public void testMaxSessions() throws Exception {
ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
qResourceAdapter.start(ctx);
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
spec.setMaxSession(1);
spec.setResourceAdapter(qResourceAdapter);
spec.setUseJNDI(false);
spec.setDestinationType("javax.jms.Queue");
spec.setDestination(MDBQUEUE);
qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
CountDownLatch latch = new CountDownLatch(1);
DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
qResourceAdapter.endpointActivation(endpointFactory, spec);
Binding binding = server.getPostOffice().getBinding(MDBQUEUEPREFIXEDSIMPLE);
assertEquals(((LocalQueueBinding) binding).getQueue().getConsumerCount(), 1);
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
qResourceAdapter.stop();
}
use of org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding in project activemq-artemis by apache.
the class ActiveMQMessageHandlerTest method testEndpointDeactivated.
@Test
public void testEndpointDeactivated() throws Exception {
ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
qResourceAdapter.start(ctx);
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
spec.setResourceAdapter(qResourceAdapter);
spec.setUseJNDI(false);
spec.setDestinationType("javax.jms.Queue");
spec.setDestination(MDBQUEUE);
qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
CountDownLatch latch = new CountDownLatch(1);
DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
qResourceAdapter.endpointActivation(endpointFactory, spec);
Binding binding = server.getPostOffice().getBinding(MDBQUEUEPREFIXEDSIMPLE);
assertEquals(((LocalQueueBinding) binding).getQueue().getConsumerCount(), 15);
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
assertEquals(((LocalQueueBinding) binding).getQueue().getConsumerCount(), 0);
assertTrue(endpoint.released);
qResourceAdapter.stop();
}
Aggregations