Message m = receiveMessage(connection1);
assertNotNull(m);
// Close consumer to cause the message to rollback.
connection1.send(consumerInfo1.createRemoveCommand());
final DestinationStatistics destinationStatistics = broker.getDestination(destination).getDestinationStatistics();
assertEquals("broker dest stat dispatched", 1, destinationStatistics.getDispatched().getCount());
assertEquals("broker dest stat dequeues", 0, destinationStatistics.getDequeues().getCount());
assertEquals("broker dest stat forwards", 0, destinationStatistics.getForwards().getCount());
// Now create remote consumer that should cause message to move to this
// remote consumer.
final ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
connection2.request(consumerInfo2);
// Make sure the message was delivered via the remote.
assertTrue("message was received", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
Message msg = receiveMessage(connection2);
if (msg != null) {
connection2.request(createAck(consumerInfo2, msg, 1, MessageAck.STANDARD_ACK_TYPE));
return true;
}
return false;
}
}));
assertTrue("broker dest stat forwards", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 1 == destinationStatistics.getForwards().getCount();
}
}));
assertEquals("broker dest stat dequeues", 1, destinationStatistics.getDequeues().getCount());
}