producingThread.join(1000);
return !producingThread.isAlive();
}
}, Wait.MAX_WAIT_MILLIS * 10));
final DestinationViewMBean view = createView(destination);
assertTrue("Not all dispatched up to default prefetch ", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return queuePrefetch == view.getDispatchCount();
}
}));
assertTrue("All have not sent have expired ", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return sendCount == view.getExpiredCount();
}
}));
LOG.info("enqueue=" + view.getEnqueueCount() + ", dequeue=" + view.getDequeueCount()
+ ", inflight=" + view.getInFlightCount() + ", expired= " + view.getExpiredCount()
+ ", size= " + view.getQueueSize());
// let the ack happen
waitCondition.countDown();
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 0 == view.getInFlightCount();
}
});
LOG.info("enqueue=" + view.getEnqueueCount() + ", dequeue=" + view.getDequeueCount()
+ ", inflight=" + view.getInFlightCount() + ", expired= " + view.getExpiredCount()
+ ", size= " + view.getQueueSize());
assertEquals("inflight didn't reduce to duck",
0, view.getInFlightCount());
assertEquals("size doesn't get back to 0 ", 0, view.getQueueSize());
assertEquals("dequeues don't match sent/expired ", sendCount, view.getDequeueCount());
// produce some more
producer.setTimeToLive(0);
long tStamp = System.currentTimeMillis();
for (int i=0; i<sendCount; i++) {
producer.send(session.createTextMessage("test-" + i));
if (i%100 == 0) {
LOG.info("sent: " + i + " @ " + ((System.currentTimeMillis() - tStamp) / 100) + "m/ms");
tStamp = System.currentTimeMillis() ;
}
}
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return received.get() >= sendCount;
}
});
consumer.close();
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 0 == view.getInFlightCount();
}
});
assertEquals("inflight did not go to zero on close", 0, view.getInFlightCount());
LOG.info("done: " + getName());
}