use of org.apache.activemq.artemis.core.server.impl.QueueImpl in project activemq-artemis by apache.
the class QueueImplTest method testName.
@Test
public void testName() {
final SimpleString name = new SimpleString("oobblle");
QueueImpl queue = getNamedQueue(name);
Assert.assertEquals(name, queue.getName());
}
use of org.apache.activemq.artemis.core.server.impl.QueueImpl in project activemq-artemis by apache.
the class QueueImplTest method testRate.
@Test
public void testRate() throws InterruptedException {
QueueImpl queue = getTemporaryQueue();
final int numMessages = 10;
for (int i = 0; i < numMessages; i++) {
MessageReference ref = generateReference(queue, i);
queue.addTail(ref);
}
Thread.sleep(1000);
float rate = queue.getRate();
Assert.assertTrue(rate <= 10.0f);
System.out.println("Rate: " + rate);
}
use of org.apache.activemq.artemis.core.server.impl.QueueImpl in project activemq-artemis by apache.
the class QueueImplTest method testResetMessagesAdded.
@Test
public void testResetMessagesAdded() throws Exception {
QueueImpl queue = getTemporaryQueue();
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
queue.addTail(messageReference);
queue.addTail(messageReference2);
Assert.assertEquals(2, getMessagesAdded(queue));
queue.resetMessagesAdded();
Assert.assertEquals(0, getMessagesAdded(queue));
}
use of org.apache.activemq.artemis.core.server.impl.QueueImpl in project activemq-artemis by apache.
the class OptimizedAckTest method testReceivedMessageNotInFlightAfterScheduledAckFires.
public void testReceivedMessageNotInFlightAfterScheduledAckFires() throws Exception {
connection.setOptimizedAckScheduledAckInterval(TimeUnit.SECONDS.toMillis(10));
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("test");
MessageProducer producer = session.createProducer(queue);
for (int i = 0; i < 10; i++) {
producer.send(session.createTextMessage("Hello" + i));
}
MessageConsumer consumer = session.createConsumer(queue);
ArtemisBrokerWrapper broker = (ArtemisBrokerWrapper) ArtemisBrokerHelper.getBroker().getBroker();
Binding binding = broker.getServer().getPostOffice().getBinding(new SimpleString("test"));
final QueueImpl coreQueue = (QueueImpl) binding.getBindable();
assertTrue("prefetch full", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 10 == coreQueue.getDeliveringCount();
}
}));
for (int i = 0; i < 6; i++) {
javax.jms.Message msg = consumer.receive(4000);
assertNotNull(msg);
assertEquals("all prefetch is still in flight: " + i, 10, coreQueue.getDeliveringCount());
}
for (int i = 6; i < 10; i++) {
javax.jms.Message msg = consumer.receive(4000);
assertNotNull(msg);
assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 3 == coreQueue.getDeliveringCount();
}
}));
}
assertTrue("After delay the scheduled ack should ack all inflight.", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
LOG.info("inflight count: " + coreQueue.getDeliveringCount());
return 0 == coreQueue.getDeliveringCount();
}
}));
}
use of org.apache.activemq.artemis.core.server.impl.QueueImpl in project activemq-artemis by apache.
the class OptimizedAckTest method testReceivedMessageStillInflight.
public void testReceivedMessageStillInflight() throws Exception {
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("test");
MessageProducer producer = session.createProducer(queue);
for (int i = 0; i < 10; i++) {
producer.send(session.createTextMessage("Hello" + i));
}
MessageConsumer consumer = session.createConsumer(queue);
// check queue delivering count is 10
ArtemisBrokerWrapper broker = (ArtemisBrokerWrapper) ArtemisBrokerHelper.getBroker().getBroker();
Binding binding = broker.getServer().getPostOffice().getBinding(new SimpleString("test"));
final QueueImpl coreQueue = (QueueImpl) binding.getBindable();
assertTrue("delivering count is 10", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 10 == coreQueue.getDeliveringCount();
}
}));
for (int i = 0; i < 6; i++) {
javax.jms.Message msg = consumer.receive(4000);
assertNotNull(msg);
assertEquals("all prefetch is still in flight: " + i, 10, coreQueue.getDeliveringCount());
}
for (int i = 6; i < 10; i++) {
javax.jms.Message msg = consumer.receive(4000);
assertNotNull(msg);
assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 3 == coreQueue.getDeliveringCount();
}
}));
}
}
Aggregations