producingThread.join(1000);
return !producingThread.isAlive();
}
}));
final DestinationViewMBean view = createView(destination);
assertTrue("all dispatched up to default prefetch ", Wait.waitFor(new Wait.Condition() {
public boolean isSatisified() throws Exception {
return queuePrefetch == view.getDispatchCount();
}
}));
assertTrue("All sent have expired ", Wait.waitFor(new Wait.Condition() {
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() {
public boolean isSatisified() throws Exception {
// consumer ackLater(delivery ack for expired messages) is based on half the prefetch value
// which will leave half of the prefetch pending till consumer close
return (queuePrefetch/2) -1 == view.getInFlightCount();
}
});
LOG.info("enqueue=" + view.getEnqueueCount() + ", dequeue=" + view.getDequeueCount()
+ ", inflight=" + view.getInFlightCount() + ", expired= " + view.getExpiredCount()
+ ", size= " + view.getQueueSize());
assertEquals("inflight reduces to half prefetch minus single delivered message", (queuePrefetch/2) -1, view.getInFlightCount());
assertEquals("size gets back to 0 ", 0, view.getQueueSize());
assertEquals("dequeues match sent/expired ", sendCount, view.getDequeueCount());
// produce some more
producer.setTimeToLive(0);
for (int i=0; i<sendCount; i++) {
producer.send(session.createTextMessage("test-" + i));
}
Wait.waitFor(new Wait.Condition() {
public boolean isSatisified() throws Exception {
return received.get() >= sendCount;
}
});
consumer.close();
Wait.waitFor(new Wait.Condition() {
public boolean isSatisified() throws Exception {
return 0 == view.getInFlightCount();
}
});
assertEquals("inflight goes to zeor on close", 0, view.getInFlightCount());
LOG.info("done: " + getName());
}