use of com.rabbitmq.client.QueueingConsumer.Delivery in project rabbitmq-java-client by rabbitmq.
the class QosTests method fairness.
@Test
public void fairness() throws IOException {
QueueingConsumer c = new QueueingConsumer(channel);
final int queueCount = 3;
final int messageCount = 100;
List<String> queues = configure(c, 1, queueCount, messageCount);
for (int i = 0; i < messageCount - 1; i++) {
List<Delivery> d = drain(c, 1);
ack(d, false);
}
// probably good enough.
for (String q : queues) {
AMQP.Queue.DeclareOk ok = channel.queueDeclarePassive(q);
assertTrue(ok.getMessageCount() < messageCount);
}
}
use of com.rabbitmq.client.QueueingConsumer.Delivery in project rabbitmq-java-client by rabbitmq.
the class QosTests method runLimitTests.
protected void runLimitTests(int limit, boolean multiAck, boolean txMode, int queueCount) throws IOException {
QueueingConsumer c = new QueueingConsumer(channel);
// We attempt to drain 'limit' messages twice, do one
// basic.get per queue, and need one message to spare
// -> 2*limit + 1*queueCount + 1
List<String> queues = configure(c, limit, queueCount, 2 * limit + 1 * queueCount + 1);
if (txMode) {
channel.txSelect();
}
// is limit enforced?
List<Delivery> d = drain(c, limit);
// is basic.get not limited?
List<Long> tags = new ArrayList<Long>();
for (String q : queues) {
GetResponse r = channel.basicGet(q, false);
assertNotNull(r);
tags.add(r.getEnvelope().getDeliveryTag());
}
// are acks handled correctly?
// and does the basic.get above have no effect on limiting?
Delivery last = ack(d, multiAck);
if (txMode) {
drain(c, 0);
channel.txRollback();
drain(c, 0);
ackDelivery(last, true);
channel.txCommit();
}
drain(c, limit);
// do acks for basic.gets have no effect on limiting?
for (long t : tags) {
channel.basicAck(t, false);
}
if (txMode) {
channel.txCommit();
}
drain(c, 0);
}
Aggregations