consumerThread.join();
producingThread.join();
session.close();
final DestinationViewMBean view = createView(destination);
// wait for all to inflight to expire
assertTrue("all inflight messages expired ", Wait.waitFor(new Wait.Condition() {
public boolean isSatisified() throws Exception {
return view.getInFlightCount() == 0;
}
}));
assertEquals("Wrong inFlightCount: ", 0, view.getInFlightCount());
LOG.info("Stats: received: " + received.get() + ", enqueues: " + view.getDequeueCount() + ", dequeues: " + view.getDequeueCount()
+ ", dispatched: " + view.getDispatchCount() + ", inflight: " + view.getInFlightCount() + ", expiries: " + view.getExpiredCount());
// wait for all sent to get delivered and expire
assertTrue("all sent messages expired ", Wait.waitFor(new Wait.Condition() {
public boolean isSatisified() throws Exception {
long oldEnqueues = view.getEnqueueCount();
Thread.sleep(200);
LOG.info("Stats: received: " + received.get() + ", size= " + view.getQueueSize() + ", enqueues: " + view.getDequeueCount() + ", dequeues: " + view.getDequeueCount()
+ ", dispatched: " + view.getDispatchCount() + ", inflight: " + view.getInFlightCount() + ", expiries: " + view.getExpiredCount());
return oldEnqueues == view.getEnqueueCount();
}
}, 60*1000));
LOG.info("Stats: received: " + received.get() + ", size= " + view.getQueueSize() + ", enqueues: " + view.getDequeueCount() + ", dequeues: " + view.getDequeueCount()
+ ", dispatched: " + view.getDispatchCount() + ", inflight: " + view.getInFlightCount() + ", expiries: " + view.getExpiredCount());
assertTrue("got at least what did not expire", received.get() >= view.getDequeueCount() - view.getExpiredCount());
assertTrue("all messages expired - queue size gone to zero " + view.getQueueSize(), Wait.waitFor(new Wait.Condition() {
public boolean isSatisified() throws Exception {
return view.getQueueSize() == 0;
}
}));
final long expiredBeforeEnqueue = numMessagesToSend - view.getEnqueueCount();
final long totalExpiredCount = view.getExpiredCount() + expiredBeforeEnqueue;
final DestinationViewMBean dlqView = createView(dlqDestination);
LOG.info("DLQ stats: size= " + dlqView.getQueueSize() + ", enqueues: " + dlqView.getDequeueCount() + ", dequeues: " + dlqView.getDequeueCount()
+ ", dispatched: " + dlqView.getDispatchCount() + ", inflight: " + dlqView.getInFlightCount() + ", expiries: " + dlqView.getExpiredCount());
Wait.waitFor(new Wait.Condition() {
public boolean isSatisified() throws Exception {
return totalExpiredCount == dlqView.getQueueSize();
}
});
assertEquals("dlq contains all expired", totalExpiredCount, dlqView.getQueueSize());
// verify DQL
MessageConsumer dlqConsumer = createDlqConsumer(connection);
int count = 0;
while (dlqConsumer.receive(4000) != null) {