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();
}
}
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();
}
}
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");
}
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();
}
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();
}
Aggregations