String messageCorrelationId = Long.toString(corellationIdGenerator.incrementAndGet());
_logger.debug("messageCorrelationId = " + messageCorrelationId);
// Initialize the count and timing controller for the new correlation id.
PerCorrelationId perCorrelationId = new PerCorrelationId();
TimingController tc = getTimingController().getControllerForCurrentThread();
perCorrelationId._tc = tc;
perCorrelationId._expectedCount = numPings;
perCorrelationIds.put(messageCorrelationId, perCorrelationId);
// Attach the chained message listener to the ping producer to listen asynchronously for the replies to these
// messages.
pingClient.setChainedMessageListener(batchedResultsListener);
// Generate a sample message of the specified size.
Message msg =
pingClient.getTestMessage(perThreadSetup._pingClient.getReplyDestinations().get(0),
testParameters.getPropertyAsInteger(PingPongProducer.MESSAGE_SIZE_PROPNAME),
testParameters.getPropertyAsBoolean(PingPongProducer.PERSISTENT_MODE_PROPNAME));
// Send the requested number of messages, and wait until they have all been received.
long timeout = Long.parseLong(testParameters.getProperty(PingPongProducer.TIMEOUT_PROPNAME));
int numReplies = pingClient.pingAndWaitForReply(msg, numPings, timeout, null);
// Check that all the replies were received and log a fail if they were not.
if (numReplies < numPings)
{
tc.completeTest(false, 0);
}
// Remove the chained message listener from the ping producer.
pingClient.removeChainedMessageListener();