diff options
Diffstat (limited to 'java/perftests/src/main')
| -rw-r--r-- | java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongBouncer.java | 10 | ||||
| -rw-r--r-- | java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java | 12 |
2 files changed, 9 insertions, 13 deletions
diff --git a/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongBouncer.java b/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongBouncer.java index d2a376fff0..e7fe180d43 100644 --- a/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongBouncer.java +++ b/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongBouncer.java @@ -125,16 +125,12 @@ public class PingPongBouncer extends AbstractPingClient implements MessageListen // Create a session to listen for messages on and one to send replies on, transactional depending on the
// command line option.
- Session consumerSession = (Session) getConnection().createSession(transacted, Session.AUTO_ACKNOWLEDGE);
- Session producerSession = (Session) getConnection().createSession(transacted, Session.AUTO_ACKNOWLEDGE);
+ _consumerSession = (Session) getConnection().createSession(transacted, Session.AUTO_ACKNOWLEDGE);
+ _producerSession = (Session) getConnection().createSession(transacted, Session.AUTO_ACKNOWLEDGE);
// Create the queue to listen for message on.
Queue q = new AMQQueue(queueName);
- MessageConsumer consumer = consumerSession.createConsumer(q, PREFETCH, NO_LOCAL, EXCLUSIVE, selector);
-
- // Hang on to the sessions for the messages and replies.
- _consumerSession = consumerSession;
- _producerSession = producerSession;
+ MessageConsumer consumer = _consumerSession.createConsumer(q, PREFETCH, NO_LOCAL, EXCLUSIVE, selector);
_verbose = verbose;
_persistent = persistent;
diff --git a/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java b/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java index 6956187b66..de8fbf9c39 100644 --- a/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java +++ b/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java @@ -215,7 +215,7 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable, }
/**
- * Primes the test loop by sending a few messages, then introducing a short wait. This allows the bounce back client
+ * Primes the test loop by sending a few messages, then introduces a short wait. This allows the bounce back client
* on the other end a chance to configure its reply producer on the reply to destination. It is also worth calling
* this a few times, in order to prime the JVMs JIT compilation.
*
@@ -309,6 +309,11 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable, String messageCorrelationId = Long.toString(idGenerator.incrementAndGet());
message.setJMSCorrelationID(messageCorrelationId);
+ // Create a count down latch to count the number of replies with. This is created before the message is sent
+ // so that the message is not received before the count down is created.
+ CountDownLatch trafficLight = new CountDownLatch(numPings);
+ trafficLights.put(messageCorrelationId, trafficLight);
+
for (int i = 0; i < numPings; i++)
{
// Re-timestamp the message.
@@ -323,17 +328,12 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable, // Keep the messageId to correlate with the reply.
//String messageId = message.getJMSMessageID();
-
if (_verbose)
{
_logger.info(timestampFormatter.format(new Date()) + ": Pinged at with correlation id, " + messageCorrelationId);
}
// Block the current thread until a reply to the message is received, or it times out.
- CountDownLatch trafficLight = new CountDownLatch(numPings);
- trafficLights.put(messageCorrelationId, trafficLight);
-
- // Note that this call expects a timeout in nanoseconds, millisecond timeout is multiplied up.
trafficLight.await(timeout, TimeUnit.MILLISECONDS);
// Work out how many replies were receieved.
|
