redeclare(q, chan);
trace("Beginning plateau of " + repeatCount + " repeats, sampling every " + sampleGranularity + " messages");
QueueingConsumer consumer = new QueueingConsumer(chan);
chan.basicConsume(q, consumer);
long startTime = System.currentTimeMillis();
for (int i = 0; i < repeatCount; i++) {
if (((i % sampleGranularity) == 0) && (i > 0)) {
long now = System.currentTimeMillis();
double delta = 1000 * (now - startTime) / (double) sampleGranularity;
plateauSampleTimes.add(now);
plateauSampleDeltas.add(delta);
System.out.print(String.format("# %3d%%; %012d --> %g microseconds/roundtrip \r",
(100 * i / repeatCount),
now,
delta));
startTime = System.currentTimeMillis();
}
chan.basicPublish("", q, props, body);
QueueingConsumer.Delivery d = consumer.nextDelivery();
chan.basicAck(d.getEnvelope().getDeliveryTag(), false);
}
System.out.println();
trace("Switching QOS to unlimited");
chan.basicQos(0);
trace("Draining backlog");
for (int i = 0; i < backlogSize; i++) {
QueueingConsumer.Delivery d = consumer.nextDelivery();
chan.basicAck(d.getEnvelope().getDeliveryTag(), false);
}
redeclare(q, chan);