use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class JmsConsumerTest method defaultAutoCreatedQueueConfigTest.
@Test
public void defaultAutoCreatedQueueConfigTest() throws Exception {
final String queueName = "q1";
server.getAddressSettingsRepository().addMatch(queueName, new AddressSettings().setDefaultMaxConsumers(5).setDefaultPurgeOnNoConsumers(true));
Connection connection = cf.createConnection();
Session session = connection.createSession();
session.createConsumer(session.createQueue(queueName));
org.apache.activemq.artemis.core.server.Queue queue = server.locateQueue(SimpleString.toSimpleString(queueName));
assertEquals(5, queue.getMaxConsumers());
assertEquals(true, queue.isPurgeOnNoConsumers());
connection.close();
}
use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class LoggingActiveMQServerPlugin method messageAcknowledged.
/**
* A message has been acknowledged
*
* @param ref The acked message
* @param reason The ack reason
* @throws ActiveMQException
*/
@Override
public void messageAcknowledged(MessageReference ref, AckReason reason) throws ActiveMQException {
if (logAll || logDeliveringEvents) {
// details - debug logging
LoggingActiveMQServerPluginLogger.LOGGER.messageAcknowledgedDetails(ref, reason);
if (LoggingActiveMQServerPluginLogger.LOGGER.isInfoEnabled()) {
Message message = (ref == null ? null : ref.getMessage());
Queue queue = (ref == null ? null : ref.getQueue());
// info level logging
LoggingActiveMQServerPluginLogger.LOGGER.messageAcknowledged((message == null ? UNAVAILABLE : Long.toString(message.getMessageID())), (ref == null ? UNAVAILABLE : ref.hasConsumerId() ? Long.toString(ref.getConsumerId()) : null), (queue == null ? UNAVAILABLE : queue.getName().toString()), reason);
}
}
}
use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class AnycastRoutingWithClusterTest method testAnycastAddressOneQueueRoutingMultiNode.
/**
* Test anycast address with single distributed queue in a 3 node cluster environment. Messages should be
* "round robin"'d across the each queue
* @throws Exception
*/
@Test
public void testAnycastAddressOneQueueRoutingMultiNode() throws Exception {
String address = "test.address";
String queueName = "test.queue";
String clusterAddress = "test";
for (int i = 0; i < 3; i++) {
setupServer(i, isFileStorage(), isNetty());
}
setupClusterConnection("cluster0", clusterAddress, MessageLoadBalancingType.STRICT, 1, isNetty(), 0, 1, 2);
setupClusterConnection("cluster1", clusterAddress, MessageLoadBalancingType.STRICT, 1, isNetty(), 1, 0, 2);
setupClusterConnection("cluster2", clusterAddress, MessageLoadBalancingType.STRICT, 1, isNetty(), 2, 0, 1);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 2);
startServers(0, 1, 2);
List<Queue> queues;
for (int i = 0; i < 3; i++) {
createAddressInfo(i, address, RoutingType.ANYCAST, -1, false);
setupSessionFactory(i, isNetty());
createQueue(i, address, queueName, null, false, RoutingType.ANYCAST);
addConsumer(i, i, queueName, null);
}
for (int i = 0; i < 3; i++) {
waitForBindings(i, address, 1, 1, true);
waitForBindings(i, address, 2, 2, false);
}
final int noMessages = 30;
send(0, address, noMessages, true, null, null);
for (int s = 0; s < 3; s++) {
final Queue queue = servers[s].locateQueue(new SimpleString(queueName));
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisfied() throws Exception {
return queue.getMessageCount() == noMessages / 3;
}
});
}
// Each consumer should receive noMessages / noServers
for (int i = 0; i < noMessages / 3; i++) {
for (int c = 0; c < 3; c++) {
assertNotNull(consumers[c].consumer.receive(1000));
}
}
}
use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class AnycastRoutingWithClusterTest method testAnycastAddressMultiQueuesWithFilterRoutingMultiNode.
/**
* Test anycast address with N queues in a 3 node cluster environment. Messages should be "round robin"'d across the
* each queue.
* @throws Exception
*/
@Test
public void testAnycastAddressMultiQueuesWithFilterRoutingMultiNode() throws Exception {
String address = "test.address";
String queueNamePrefix = "test.queue";
String clusterAddress = "test";
for (int i = 0; i < 3; i++) {
setupServer(i, isFileStorage(), isNetty());
}
setupClusterConnection("cluster0", clusterAddress, MessageLoadBalancingType.STRICT, 1, isNetty(), 0, 1, 2);
setupClusterConnection("cluster1", clusterAddress, MessageLoadBalancingType.STRICT, 1, isNetty(), 1, 0, 2);
setupClusterConnection("cluster2", clusterAddress, MessageLoadBalancingType.STRICT, 1, isNetty(), 2, 0, 1);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 2);
startServers(0, 1, 2);
List<Queue> queues;
for (int i = 0; i < 3; i++) {
createAddressInfo(i, address, RoutingType.ANYCAST, -1, false);
setupSessionFactory(i, isNetty());
}
String filter1 = "giraffe";
String filter2 = "platypus";
createQueue(0, address, queueNamePrefix + 0, filter1, false, RoutingType.ANYCAST);
createQueue(1, address, queueNamePrefix + 1, filter1, false, RoutingType.ANYCAST);
createQueue(2, address, queueNamePrefix + 2, filter2, false, RoutingType.ANYCAST);
for (int i = 0; i < 3; i++) {
addConsumer(i, i, queueNamePrefix + i, null);
}
for (int i = 0; i < 3; i++) {
waitForBindings(i, address, 1, 1, true);
waitForBindings(i, address, 2, 2, false);
}
final int noMessages = 30;
send(0, address, noMessages, true, filter1, null);
// Each consumer should receive noMessages / noServers
for (int i = 0; i < noMessages / 2; i++) {
for (int c = 0; c < 2; c++) {
assertNotNull(consumers[c].consumer.receive(1000));
}
}
assertNull(consumers[2].consumer.receive(1000));
}
use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class SessionTest method testRollbackWithSend.
@Test
public void testRollbackWithSend() throws Exception {
cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, false, true);
clientSession.createQueue(queueName, queueName, false);
ClientProducer cp = clientSession.createProducer(queueName);
cp.send(clientSession.createMessage(false));
cp.send(clientSession.createMessage(false));
cp.send(clientSession.createMessage(false));
cp.send(clientSession.createMessage(false));
cp.send(clientSession.createMessage(false));
cp.send(clientSession.createMessage(false));
cp.send(clientSession.createMessage(false));
cp.send(clientSession.createMessage(false));
cp.send(clientSession.createMessage(false));
cp.send(clientSession.createMessage(false));
Queue q = (Queue) server.getPostOffice().getBinding(new SimpleString(queueName)).getBindable();
Assert.assertEquals(0, getMessageCount(q));
clientSession.rollback();
cp.send(clientSession.createMessage(false));
cp.send(clientSession.createMessage(false));
clientSession.commit();
Assert.assertEquals(2, getMessageCount(q));
clientSession.close();
}
Aggregations