consumerInfo1.setPrefetchSize(1);
connection1.send(consumerInfo1);
// Send the messages.
for (int i = 0; i < 4; i++) {
Message message = createMessage(producerInfo, destination, deliveryMode);
message.setGroupID("TEST-GROUP");
message.setGroupSequence(i + 1);
connection1.request(message);
}
// Setup a second connection
StubConnection connection2 = createConnection();
ConnectionInfo connectionInfo2 = createConnectionInfo();
SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
connection2.send(connectionInfo2);
connection2.send(sessionInfo2);
ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
consumerInfo2.setPrefetchSize(1);
connection2.send(consumerInfo2);
// All the messages should have been sent down connection 1.. just get
// the first 3
for (int i = 0; i < 3; i++) {
Message m1 = receiveMessage(connection1);
assertNotNull("m1 is null for index: " + i, m1);
connection1.send(createAck(consumerInfo1, m1, 1, MessageAck.STANDARD_ACK_TYPE));
}
// Close the first consumer.
connection1.request(closeConsumerInfo(consumerInfo1));
// The last messages should now go the the second consumer.
for (int i = 0; i < 1; i++) {
Message m1 = receiveMessage(connection2);
assertNotNull("m1 is null for index: " + i, m1);
connection2.request(createAck(consumerInfo2, m1, 1, MessageAck.STANDARD_ACK_TYPE));
}
assertNoMessagesLeft(connection2);