summaryrefslogtreecommitdiff
path: root/qpid
diff options
context:
space:
mode:
authorBhupendra Bhusman Bhardwaj <bhupendrab@apache.org>2007-01-19 10:28:50 +0000
committerBhupendra Bhusman Bhardwaj <bhupendrab@apache.org>2007-01-19 10:28:50 +0000
commitfc0633f1358f6036e1663d8839e01aef4b347c68 (patch)
treed9c7da0131e961a3e1032a8c4364a6dd97e69823 /qpid
parent8e34903c0ea7167f03a97eae61c5e41dd0434eee (diff)
downloadqpid-python-fc0633f1358f6036e1663d8839e01aef4b347c68.tar.gz
refactored the constructor to allow subclasses use the super constructor
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@497766 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid')
-rw-r--r--qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java67
1 files changed, 50 insertions, 17 deletions
diff --git a/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java b/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
index de8fbf9c39..00b01f1025 100644
--- a/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
+++ b/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
@@ -70,25 +70,25 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable,
private static final Logger _logger = Logger.getLogger(PingPongProducer.class);
/** Used to set up a default message size. */
- private static final int DEFAULT_MESSAGE_SIZE = 0;
+ protected static final int DEFAULT_MESSAGE_SIZE = 0;
/** Used to define how long to wait between pings. */
- private static final long SLEEP_TIME = 250;
+ protected static final long SLEEP_TIME = 250;
/** Used to define how long to wait before assuming that a ping has timed out. */
- private static final long TIMEOUT = 3000;
+ protected static final long TIMEOUT = 9000;
/** Holds the name of the queue to send pings on. */
private static final String PING_QUEUE_NAME = "ping";
/** The batch size. */
- private static final int BATCH_SIZE = 100;
+ protected static final int BATCH_SIZE = 100;
/** Keeps track of the ping producer instance used in the run loop. */
private static PingPongProducer _pingProducer;
- private static final int PREFETCH = 100;
- private static final boolean NO_LOCAL = true;
- private static final boolean EXCLUSIVE = false;
+ protected static final int PREFETCH = 100;
+ protected static final boolean NO_LOCAL = true;
+ protected static final boolean EXCLUSIVE = false;
/** The number of priming loops to run. */
private static final int PRIMING_LOOPS = 3;
@@ -102,6 +102,9 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable,
/** Holds the queue to send the ping replies to. */
private Queue _replyQueue;
+ /** Hold the known Queue where the producer will be sending message to*/
+ private Queue _pingQueue;
+
/** Determines whether this producer sends persistent messages from the run method. */
private boolean _persistent;
@@ -144,26 +147,56 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable,
setProducerSession((Session) getConnection().createSession(transacted, Session.AUTO_ACKNOWLEDGE));
_consumerSession = (Session) getConnection().createSession(transacted, Session.AUTO_ACKNOWLEDGE);
+ // Create producer and the consumer
+ createProducer(queueName, persistent);
+ createConsumer(selector);
+
+ // Run a few priming pings to remove warm up time from test results.
+ prime(PRIMING_LOOPS);
+
+ _persistent = persistent;
+ _messageSize = messageSize;
+ _verbose = verbose;
+ }
+
+ /**
+ * Creates the queue and producer to send the pings on
+ * @param queueName
+ * @param persistent
+ * @throws JMSException
+ */
+ public void createProducer(String queueName, boolean persistent) throws JMSException
+ {
// Create a queue and producer to send the pings on.
- Queue pingQueue = new AMQQueue(queueName);
- _producer = (MessageProducer) getProducerSession().createProducer(pingQueue);
+ _pingQueue = new AMQQueue(queueName);
+ _producer = (MessageProducer) getProducerSession().createProducer(_pingQueue);
_producer.setDisableMessageTimestamp(true);
_producer.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
+ }
+ /**
+ * Creates the temporary queue to listen to the responses
+ * @param selector
+ * @throws JMSException
+ */
+ public void createConsumer(String selector) throws JMSException
+ {
// Create a temporary queue to get the pongs on.
_replyQueue = _consumerSession.createTemporaryQueue();
// Create a message consumer to get the replies with and register this to be called back by it.
MessageConsumer consumer = _consumerSession.createConsumer(_replyQueue, PREFETCH, NO_LOCAL, EXCLUSIVE, selector);
consumer.setMessageListener(this);
+ }
- // Run a few priming pings to remove warm up time from test results.
- prime(PRIMING_LOOPS);
-
- _persistent = persistent;
- _messageSize = messageSize;
+ protected Session getConsumerSession()
+ {
+ return _consumerSession;
+ }
- _verbose = verbose;
+ public Queue getPingQueue()
+ {
+ return _pingQueue;
}
/**
@@ -185,8 +218,8 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable,
// Extract the command line.
if (args.length < 2)
{
- System.err.println(
- "Usage: TestPingPublisher <brokerDetails> <virtual path> [transacted] [persistent] [message size in bytes]");
+ System.err.println("Usage: TestPingPublisher <brokerDetails> <virtual path> [verbose (true/false)] " +
+ "[transacted (true/false)] [persistent (true/false)] [message size in bytes]");
System.exit(0);
}