summaryrefslogtreecommitdiff
path: root/java/perftests/src/main
diff options
context:
space:
mode:
authorRobert Greig <rgreig@apache.org>2007-01-18 16:58:35 +0000
committerRobert Greig <rgreig@apache.org>2007-01-18 16:58:35 +0000
commit626893644f5ec582edad809b59b8cc8e3356b3bc (patch)
treea9977b82b48561380f0efaaa8e8776331faf1018 /java/perftests/src/main
parent480b852b65800d05f83d6061b80eb08cb09ad1fb (diff)
downloadqpid-python-626893644f5ec582edad809b59b8cc8e3356b3bc.tar.gz
(Pacth by Rupert Smith) Fixed mistake in PingPongProducer, it was creating its message counter after
sending messages, so sometimes the onMessage loop had already received mesages before the counter was created. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@497498 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/perftests/src/main')
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongBouncer.java10
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java12
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.