use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class QosTests method limitIncrease.
@Test
public void limitIncrease() throws IOException {
QueueingConsumer c = new QueueingConsumer(channel);
configure(c, 1, 3);
channel.basicQos(2, true);
drain(c, 1);
}
use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class QosTests method singleChannelAndQueueFairness.
@Test
public void singleChannelAndQueueFairness() throws IOException {
// check that when we have multiple consumers on the same
// channel & queue, and a prefetch limit set, that all
// consumers get a fair share of the messages.
channel.basicQos(1, true);
String q = channel.queueDeclare().getQueue();
channel.queueBind(q, "amq.fanout", "");
final Map<String, Integer> counts = Collections.synchronizedMap(new HashMap<String, Integer>());
QueueingConsumer c = new QueueingConsumer(channel) {
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
counts.put(consumerTag, counts.get(consumerTag) + 1);
super.handleDelivery(consumerTag, envelope, properties, body);
}
};
channel.basicConsume(q, false, "c1", c);
channel.basicConsume(q, false, "c2", c);
int count = 10;
counts.put("c1", 0);
counts.put("c2", 0);
fill(count);
try {
for (int i = 0; i < count; i++) {
Delivery d = c.nextDelivery();
channel.basicAck(d.getEnvelope().getDeliveryTag(), false);
}
} catch (InterruptedException ie) {
fail("interrupted");
}
// we only check that the server isn't grossly unfair; perfect
// fairness is too much to ask for (even though RabbitMQ atm
// does actually provide it in this case)
assertTrue(counts.get("c1").intValue() > 0);
assertTrue(counts.get("c2").intValue() > 0);
}
use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class QosTests method limitInheritsUnackedCount.
@Test
public void limitInheritsUnackedCount() throws IOException {
QueueingConsumer c = new QueueingConsumer(channel);
declareBindConsume(c);
fill(1);
drain(c, 1);
channel.basicQos(2, true);
fill(2);
drain(c, 1);
}
use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class QosTests method limitDecrease.
@Test
public void limitDecrease() throws IOException {
QueueingConsumer c = new QueueingConsumer(channel);
List<Delivery> d = configure(c, 2, 4);
channel.basicQos(1, true);
drain(c, 0);
ack(d, true);
drain(c, 1);
}
use of com.rabbitmq.client.QueueingConsumer in project rabbitmq-java-client by rabbitmq.
the class QosTests method noAckNoAlterLimit.
@Test
public void noAckNoAlterLimit() throws IOException {
QueueingConsumer c = new QueueingConsumer(channel);
declareBindConsume(channel, c, true);
channel.basicQos(1, true);
fill(2);
drain(c, 2);
}
Aggregations