use of org.apache.activemq.artemis.core.server.QueueQueryResult in project activemq-artemis by apache.
the class FullQualifiedQueueTest method testMixedQueues.
@Test
public void testMixedQueues() throws Exception {
server.createQueue(mixedAddress, RoutingType.MULTICAST, multicastQ1, null, true, false, -1, false, true);
server.createQueue(mixedAddress, RoutingType.MULTICAST, multicastQ2, null, true, false, -1, false, true);
server.createQueue(mixedAddress, RoutingType.MULTICAST, multicastQ3, null, true, false, -1, false, true);
server.createQueue(mixedAddress, RoutingType.ANYCAST, anycastQ1, null, true, false, -1, false, true);
server.createQueue(mixedAddress, RoutingType.ANYCAST, anycastQ2, null, true, false, -1, false, true);
server.createQueue(mixedAddress, RoutingType.ANYCAST, anycastQ3, null, true, false, -1, false, true);
ClientSessionFactory cf = createSessionFactory(locator);
ClientSession session = cf.createSession();
session.start();
// send 3 messages
ClientProducer producer = session.createProducer(mixedAddress);
final int num = 3;
sendMessages(session, producer, num);
ClientConsumer consumer1 = session.createConsumer(toFullQN(mixedAddress, anycastQ1));
ClientConsumer consumer2 = session.createConsumer(toFullQN(mixedAddress, anycastQ2));
ClientConsumer consumer3 = session.createConsumer(toFullQN(mixedAddress, anycastQ3));
ClientConsumer consumer4 = session.createConsumer(toFullQN(mixedAddress, multicastQ1));
ClientConsumer consumer5 = session.createConsumer(toFullQN(mixedAddress, multicastQ2));
ClientConsumer consumer6 = session.createConsumer(toFullQN(mixedAddress, multicastQ3));
session.start();
// each anycast consumer receives one, each multicast receives three.
ClientMessage m = consumer1.receive(2000);
assertNotNull(m);
System.out.println("consumer1 : " + m);
m.acknowledge();
m = consumer2.receive(2000);
assertNotNull(m);
System.out.println("consumer2 : " + m);
m.acknowledge();
m = consumer3.receive(2000);
assertNotNull(m);
System.out.println("consumer3 : " + m);
m.acknowledge();
for (int i = 0; i < num; i++) {
m = consumer4.receive(2000);
assertNotNull(m);
System.out.println("consumer4 : " + m);
m.acknowledge();
m = consumer5.receive(2000);
assertNotNull(m);
System.out.println("consumer5 : " + m);
m.acknowledge();
m = consumer6.receive(2000);
assertNotNull(m);
System.out.println("consumer6 : " + m);
m.acknowledge();
}
session.commit();
// queues are empty now
for (SimpleString q : new SimpleString[] { anycastQ1, anycastQ2, anycastQ3, multicastQ1, multicastQ2, multicastQ3 }) {
QueueQueryResult query = server.queueQuery(toFullQN(mixedAddress, q));
assertTrue(query.isExists());
assertEquals(mixedAddress, query.getAddress());
assertEquals(toFullQN(mixedAddress, q), query.getName());
assertEquals(0, query.getMessageCount());
}
}
use of org.apache.activemq.artemis.core.server.QueueQueryResult in project activemq-artemis by apache.
the class FullQualifiedQueueTest method testAnycastQueues.
@Test
public void testAnycastQueues() throws Exception {
server.createQueue(anycastAddress, RoutingType.ANYCAST, anycastQ1, null, true, false, -1, false, true);
server.createQueue(anycastAddress, RoutingType.ANYCAST, anycastQ2, null, true, false, -1, false, true);
server.createQueue(anycastAddress, RoutingType.ANYCAST, anycastQ3, null, true, false, -1, false, true);
ClientSessionFactory cf = createSessionFactory(locator);
ClientSession session = cf.createSession();
session.start();
// send 3 messages
ClientProducer producer = session.createProducer(anycastAddress);
sendMessages(session, producer, 3);
ClientConsumer consumer1 = session.createConsumer(toFullQN(anycastAddress, anycastQ1));
ClientConsumer consumer2 = session.createConsumer(toFullQN(anycastAddress, anycastQ2));
ClientConsumer consumer3 = session.createConsumer(toFullQN(anycastAddress, anycastQ3));
session.start();
// each consumer receives one
ClientMessage m = consumer1.receive(2000);
assertNotNull(m);
m.acknowledge();
m = consumer2.receive(2000);
assertNotNull(m);
m.acknowledge();
m = consumer3.receive(2000);
assertNotNull(m);
m.acknowledge();
session.commit();
// queues are empty now
for (SimpleString q : new SimpleString[] { anycastQ1, anycastQ2, anycastQ3 }) {
QueueQueryResult query = server.queueQuery(toFullQN(anycastAddress, q));
assertTrue(query.isExists());
assertEquals(anycastAddress, query.getAddress());
assertEquals(toFullQN(anycastAddress, q), query.getName());
assertEquals(0, query.getMessageCount());
}
}
use of org.apache.activemq.artemis.core.server.QueueQueryResult 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.server.QueueQueryResult 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.server.QueueQueryResult in project activemq-artemis by apache.
the class FQQNStompTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
conn = StompClientConnectionFactory.createClientConnection(uri);
QueueQueryResult result = server.getActiveMQServer().queueQuery(new SimpleString(getQueueName()));
assertTrue(result.isExists());
System.out.println("address: " + result.getAddress() + " queue " + result.getName());
}
Aggregations