use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class SlowConsumerTest method testMultipleConsumersOneQueue.
/**
* This test creates 3 consumers on one queue. A producer sends
* messages at a rate of 2 messages per second. Each consumer
* consumes messages at rate of 1 message per second. The slow
* consumer threshold is 1 message per second.
* Based on the above settings, slow consumer removal will not
* be performed (2 < 3*1), so no consumer will be removed during the
* test, and all messages will be received.
*/
@Test
public void testMultipleConsumersOneQueue() throws Exception {
locator.setAckBatchSize(0);
Queue queue = server.locateQueue(QUEUE);
ClientSessionFactory sf1 = createSessionFactory(locator);
ClientSessionFactory sf2 = createSessionFactory(locator);
ClientSessionFactory sf3 = createSessionFactory(locator);
ClientSessionFactory sf4 = createSessionFactory(locator);
final int messages = 10 * threshold;
FixedRateProducer producer = new FixedRateProducer(threshold * 2, sf1, QUEUE, messages);
final Set<FixedRateConsumer> consumers = new ConcurrentHashSet<>();
final Set<ClientMessage> receivedMessages = new ConcurrentHashSet<>();
consumers.add(new FixedRateConsumer(threshold, receivedMessages, sf2, QUEUE, 1));
consumers.add(new FixedRateConsumer(threshold, receivedMessages, sf3, QUEUE, 2));
consumers.add(new FixedRateConsumer(threshold, receivedMessages, sf4, QUEUE, 3));
try {
producer.start();
for (FixedRateConsumer consumer : consumers) {
consumer.start();
}
producer.join(10000);
assertTrue(TimeUtils.waitOnBoolean(true, 10000, () -> receivedMessages.size() == messages));
Assert.assertEquals(3, queue.getConsumerCount());
} finally {
producer.stopRunning();
Assert.assertFalse(producer.failed);
for (FixedRateConsumer consumer : consumers) {
consumer.stopRunning();
Assert.assertFalse(consumer.failed);
}
logger.debug("***report messages received: " + receivedMessages.size());
logger.debug("***consumers left: " + consumers.size());
}
}
use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class SessionCreateAndDeleteQueueTest method testTemporaryTrue.
@Test
public void testTemporaryTrue() throws Exception {
ClientSession session = createSessionFactory(locator).createSession(false, true, true);
session.createTemporaryQueue(address, queueName);
Binding binding = server.getPostOffice().getBinding(queueName);
Queue q = (Queue) binding.getBindable();
Assert.assertTrue(q.isTemporary());
session.close();
}
use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class SessionCreateAndDeleteQueueTest method testcreateWithFilter.
@Test
public void testcreateWithFilter() throws Exception {
ClientSession session = createSessionFactory(locator).createSession(false, true, true);
SimpleString filterString = new SimpleString("x=y");
session.createQueue(address, queueName, filterString, false);
Binding binding = server.getPostOffice().getBinding(queueName);
Queue q = (Queue) binding.getBindable();
Assert.assertEquals(q.getFilter().getFilterString(), filterString);
session.close();
}
use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class SessionCreateAndDeleteQueueTest method testDurableFalse.
@Test
public void testDurableFalse() throws Exception {
ClientSession session = createSessionFactory(locator).createSession(false, true, true);
session.createQueue(address, queueName, false);
Binding binding = server.getPostOffice().getBinding(queueName);
Queue q = (Queue) binding.getBindable();
Assert.assertFalse(q.isDurable());
session.close();
}
use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class TransactionalSendTest method testSendWithCommit.
@Test
public void testSendWithCommit() throws Exception {
ActiveMQServer server = createServer(false);
server.start();
ClientSessionFactory cf = createSessionFactory(locator);
ClientSession session = cf.createSession(false, false, false);
session.createQueue(addressA, queueA, false);
ClientProducer cp = session.createProducer(addressA);
int numMessages = 100;
for (int i = 0; i < numMessages; i++) {
cp.send(session.createMessage(false));
}
Queue q = (Queue) server.getPostOffice().getBinding(queueA).getBindable();
Assert.assertEquals(0, getMessageCount(q));
session.commit();
Assert.assertEquals(getMessageCount(q), numMessages);
// now send some more
for (int i = 0; i < numMessages; i++) {
cp.send(session.createMessage(false));
}
Assert.assertEquals(numMessages, getMessageCount(q));
session.commit();
Assert.assertEquals(numMessages * 2, getMessageCount(q));
session.close();
}
Aggregations