From 385cc184361c6d58d56fb696e4eeb0f6ad511fa0 Mon Sep 17 00:00:00 2001 From: Bhupendra Bhusman Bhardwaj Date: Wed, 25 Apr 2007 14:46:03 +0000 Subject: Made the return type of getTestMessage() to a generic type for subclass to override. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@532372 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/ping/PingSendOnlyClient.java | 18 +++++++++++++++++- .../org/apache/qpid/requestreply/PingPongProducer.java | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'java/perftests/src/main') diff --git a/java/perftests/src/main/java/org/apache/qpid/ping/PingSendOnlyClient.java b/java/perftests/src/main/java/org/apache/qpid/ping/PingSendOnlyClient.java index 7cf5e4516f..29757a20ba 100644 --- a/java/perftests/src/main/java/org/apache/qpid/ping/PingSendOnlyClient.java +++ b/java/perftests/src/main/java/org/apache/qpid/ping/PingSendOnlyClient.java @@ -6,6 +6,12 @@ import java.util.Properties; import org.apache.log4j.Logger; import org.apache.qpid.util.CommandLineParser; +import org.apache.qpid.client.message.TestMessageFactory; + +import javax.jms.ObjectMessage; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; /** *

@@ -32,7 +38,7 @@ public class PingSendOnlyClient extends PingDurableClient { // Create a ping producer overriding its defaults with all options passed on the command line. Properties options = CommandLineParser.processCommandLine(args, new CommandLineParser(new String[][] {})); - PingDurableClient pingProducer = new PingSendOnlyClient(options); + PingSendOnlyClient pingProducer = new PingSendOnlyClient(options); // Create a shutdown hook to terminate the ping-pong producer. Runtime.getRuntime().addShutdownHook(pingProducer.getShutdownHook()); @@ -54,4 +60,14 @@ public class PingSendOnlyClient extends PingDurableClient System.exit(1); } } + + public Message getTestMessage(Destination replyQueue, int messageSize, boolean persistent) throws JMSException + { + Message msg = TestMessageFactory.newTextMessage(_producerSession, messageSize); + + // Timestamp the message in nanoseconds. + msg.setLongProperty(MESSAGE_TIMESTAMP_PROPNAME, System.nanoTime()); + + return msg; + } } 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 ecaf27167f..5dec2125ee 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 @@ -1049,7 +1049,7 @@ public class PingPongProducer implements Runnable, MessageListener, ExceptionLis try { // Generate a sample message and time stamp it. - ObjectMessage msg = getTestMessage(_replyDestination, _messageSize, _persistent); + Message msg = getTestMessage(_replyDestination, _messageSize, _persistent); msg.setLongProperty(MESSAGE_TIMESTAMP_PROPNAME, System.nanoTime()); // Send the message and wait for a reply. @@ -1096,7 +1096,7 @@ public class PingPongProducer implements Runnable, MessageListener, ExceptionLis * * @throws javax.jms.JMSException All underlying JMSException are allowed to fall through. */ - public ObjectMessage getTestMessage(Destination replyQueue, int messageSize, boolean persistent) throws JMSException + public Message getTestMessage(Destination replyQueue, int messageSize, boolean persistent) throws JMSException { ObjectMessage msg = TestMessageFactory.newObjectMessage(_producerSession, replyQueue, messageSize, persistent); -- cgit v1.2.1
CRC Card