From 6124bfefc65a76435a8fb334cf9826cc8bff6b37 Mon Sep 17 00:00:00 2001 From: Robert Greig Date: Fri, 13 Apr 2007 10:17:12 +0000 Subject: Created new ping client that sends messages only. Usefull for examaning known queue states in mgmnt console. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@528424 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/ping/PingDurableClient.java | 11 ++++- .../org/apache/qpid/ping/PingSendOnlyClient.java | 57 ++++++++++++++++++++++ .../apache/qpid/requestreply/PingPongProducer.java | 2 +- 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 java/perftests/src/main/java/org/apache/qpid/ping/PingSendOnlyClient.java (limited to 'java') diff --git a/java/perftests/src/main/java/org/apache/qpid/ping/PingDurableClient.java b/java/perftests/src/main/java/org/apache/qpid/ping/PingDurableClient.java index d56d31a1df..0e832ef100 100644 --- a/java/perftests/src/main/java/org/apache/qpid/ping/PingDurableClient.java +++ b/java/perftests/src/main/java/org/apache/qpid/ping/PingDurableClient.java @@ -1,3 +1,4 @@ +/* Copyright Rupert Smith, 2005 to 2006, all rights reserved. */ /* * * Licensed to the Apache Software Foundation (ASF) under one @@ -178,6 +179,7 @@ public class PingDurableClient extends PingPongProducer implements ExceptionList // Run the test procedure. int sent = pingProducer.send(); + pingProducer.closeConnection(); pingProducer.waitForUser("Press return to begin receiving the pings."); pingProducer.receive(sent); @@ -302,6 +304,13 @@ public class PingDurableClient extends PingPongProducer implements ExceptionList System.out.println("Messages sent: " + messagesSent + ", Messages Committed = " + messagesCommitted + ", Messages not Committed = " + messagesNotCommitted); + + + return messagesSent; + } + + protected void closeConnection() + { // Clean up the connection. try { @@ -314,8 +323,6 @@ public class PingDurableClient extends PingPongProducer implements ExceptionList // Ignore as did best could manage to clean up. } - - return messagesSent; } protected void receive(int messagesSent) throws Exception 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 new file mode 100644 index 0000000000..7cf5e4516f --- /dev/null +++ b/java/perftests/src/main/java/org/apache/qpid/ping/PingSendOnlyClient.java @@ -0,0 +1,57 @@ +/* Copyright Rupert Smith, 2005 to 2006, all rights reserved. */ +package org.apache.qpid.ping; + +import java.util.Properties; + +import org.apache.log4j.Logger; + +import org.apache.qpid.util.CommandLineParser; + +/** + *

+ *
CRC Card
Responsibilities Collaborations + *
+ */ +public class PingSendOnlyClient extends PingDurableClient +{ + private static final Logger log = Logger.getLogger(PingSendOnlyClient.class); + + public PingSendOnlyClient(Properties overrides) throws Exception + { + super(overrides); + } + + /** + * Starts the ping/wait/receive process. + * + * @param args The command line arguments. + */ + public static void main(String[] args) + { + try + { + // 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); + + // Create a shutdown hook to terminate the ping-pong producer. + Runtime.getRuntime().addShutdownHook(pingProducer.getShutdownHook()); + + // Ensure that the ping pong producer is registered to listen for exceptions on the connection too. + // pingProducer.getConnection().setExceptionListener(pingProducer); + + // Run the test procedure. + int sent = pingProducer.send(); + pingProducer.waitForUser("Press return to close connection and quit."); + pingProducer.closeConnection(); + + System.exit(0); + } + catch (Exception e) + { + System.err.println(e.getMessage()); + log.error("Top level handler caught execption.", e); + System.exit(1); + } + } +} 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 ce0181558f..ecaf27167f 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 @@ -1301,7 +1301,7 @@ public class PingPongProducer implements Runnable, MessageListener, ExceptionLis * * @param prompt The prompt to display on the console. */ - protected void waitForUser(String prompt) + public void waitForUser(String prompt) { System.out.println(prompt); -- cgit v1.2.1