summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/distribution/pom.xml5
-rw-r--r--java/distribution/src/main/assembly/bin.xml8
-rwxr-xr-xjava/perftests/bin/serviceProvidingClient.sh8
-rwxr-xr-xjava/perftests/bin/serviceRequestingClient.sh8
-rwxr-xr-xjava/perftests/bin/setupclasspath.sh1
-rwxr-xr-xjava/perftests/bin/testPingClient.sh33
-rwxr-xr-xjava/perftests/bin/testPingProducer.sh33
-rwxr-xr-xjava/perftests/bin/testPingPublisher.sh33
-rwxr-xr-xjava/perftests/bin/testPingSubscriber.sh33
-rw-r--r--java/perftests/pom.xml30
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingClient.java138
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingProducer.java223
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingPublisher.java188
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingSubscriber.java134
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceRequestingClient.java6
-rw-r--r--java/perftests/src/main/java/perftests.log4j31
-rw-r--r--java/pom.xml1
17 files changed, 907 insertions, 6 deletions
diff --git a/java/distribution/pom.xml b/java/distribution/pom.xml
index df879c9c95..59b4107454 100644
--- a/java/distribution/pom.xml
+++ b/java/distribution/pom.xml
@@ -62,6 +62,11 @@
<version>${pom.version}</version>
</dependency>
<dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>qpid-perftests</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
<groupId>${pom.groupId}.management</groupId>
<artifactId>org.apache.qpid.management.ui</artifactId>
<version>${pom.version}</version>
diff --git a/java/distribution/src/main/assembly/bin.xml b/java/distribution/src/main/assembly/bin.xml
index 00ffd86bd0..fa3ed7dd06 100644
--- a/java/distribution/src/main/assembly/bin.xml
+++ b/java/distribution/src/main/assembly/bin.xml
@@ -66,6 +66,14 @@
<include>qpid-incubating.jar</include>
</includes>
</fileSet>
+ <fileSet>
+ <directory>../perftests/bin</directory>
+ <outputDirectory>qpid-${qpid.version}/bin/perftests</outputDirectory>
+ <includes>
+ <include>*</include>
+ </includes>
+ </fileSet>
+
</fileSets>
<files>
<!-- due to a bug in the assembly plugin (MASSEMBLY-153) you have
diff --git a/java/perftests/bin/serviceProvidingClient.sh b/java/perftests/bin/serviceProvidingClient.sh
index 207e4439f1..3434e6a667 100755
--- a/java/perftests/bin/serviceProvidingClient.sh
+++ b/java/perftests/bin/serviceProvidingClient.sh
@@ -19,7 +19,13 @@
#
# XXX -Xms1024m -XX:NewSize=300m
+
+if [[ $# != 1 ]] ; then
+ echo "usage: ./serviceProvidingClient.sh <brokerdetails>"
+ exit 1
+fi
+
. ./setupclasspath.sh
echo $CP
# usage: just pass in the host(s)
-$JAVA_HOME/bin/java -cp $CP org.apache.qpid.requestreply.ServiceProvidingClient $1 guest guest /test serviceQ
+$JAVA_HOME/bin/java -cp $CP -Damqj.logging.level="warn" -Damqj.test.logging.level="info" -Dlog4j.configuration=perftests.log4j org.apache.qpid.requestreply.ServiceProvidingClient $1 guest guest /test serviceQ
diff --git a/java/perftests/bin/serviceRequestingClient.sh b/java/perftests/bin/serviceRequestingClient.sh
index 7dd3d63c27..55ae8d5f52 100755
--- a/java/perftests/bin/serviceRequestingClient.sh
+++ b/java/perftests/bin/serviceRequestingClient.sh
@@ -18,10 +18,16 @@
# under the License.
#
# args supplied: <host:port> <num messages>
+#
+if [[ $# < 2 ]] ; then
+ echo "usage: ./serviceRequestingClient.sh <brokerdetails> <number of messages> [<message size 4096b default>]"
+ exit 1
+fi
+
thehosts=$1
shift
echo $thehosts
# XXX -Xms1024m -XX:NewSize=300m
. ./setupclasspath.sh
echo $CP
-$JAVA_HOME/bin/java -cp $CP -Damqj.logging.level="INFO" org.apache.qpid.requestreply.ServiceRequestingClient $thehosts guest guest /test serviceQ "$@"
+$JAVA_HOME/bin/java -cp $CP -Damqj.logging.level="warn" -Damqj.test.logging.level="info" -Dlog4j.configuration=perftests.log4j org.apache.qpid.requestreply.ServiceRequestingClient $thehosts guest guest /test serviceQ "$@"
diff --git a/java/perftests/bin/setupclasspath.sh b/java/perftests/bin/setupclasspath.sh
index a660392e77..29ca661aab 100755
--- a/java/perftests/bin/setupclasspath.sh
+++ b/java/perftests/bin/setupclasspath.sh
@@ -7,3 +7,4 @@ CP=$QPID_HOME/lib/qpid-incubating.jar:../target/classes
if [ `uname -o` == "Cygwin" ] ; then
CP=`cygpath --path --windows $CP`
fi
+
diff --git a/java/perftests/bin/testPingClient.sh b/java/perftests/bin/testPingClient.sh
new file mode 100755
index 0000000000..1e96b1c996
--- /dev/null
+++ b/java/perftests/bin/testPingClient.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# args supplied: <host:port>
+#
+if [[ $# < 1 ]] ; then
+ echo "usage: ./testPingClient.sh <host details> [<selector>]"
+ exit 1
+fi
+
+thehosts=$1
+shift
+echo $thehosts
+# XXX -Xms1024m -XX:NewSize=300m
+. ./setupclasspath.sh
+echo $CP
+$JAVA_HOME/bin/java -cp $CP -Damqj.logging.level="warn" -Damqj.test.logging.level="info" -Dlog4j.configuration=perftests.log4j org.apache.qpid.pingpong.TestPingClient $thehosts guest guest /test "$@"
diff --git a/java/perftests/bin/testPingProducer.sh b/java/perftests/bin/testPingProducer.sh
new file mode 100755
index 0000000000..29e09a6f03
--- /dev/null
+++ b/java/perftests/bin/testPingProducer.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# args supplied: <host:port>
+#
+if [[ $# < 1 ]] ; then
+ echo "usage: ./testPingProducer.sh <host details> [<selector>]"
+ exit 1
+fi
+
+thehosts=$1
+shift
+echo $thehosts
+# XXX -Xms1024m -XX:NewSize=300m
+. ./setupclasspath.sh
+echo $CP
+$JAVA_HOME/bin/java -cp $CP -Damqj.logging.level="warn" -Damqj.test.logging.level="info" -Dlog4j.configuration=perftests.log4j org.apache.qpid.pingpong.TestPingProducer $thehosts /test
diff --git a/java/perftests/bin/testPingPublisher.sh b/java/perftests/bin/testPingPublisher.sh
new file mode 100755
index 0000000000..61ed98d3e7
--- /dev/null
+++ b/java/perftests/bin/testPingPublisher.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# args supplied: <host:port>
+#
+if [[ $# < 1 ]] ; then
+ echo "usage: ./testPingPublisher.sh <host details>"
+ exit 1
+fi
+
+thehosts=$1
+shift
+echo $thehosts
+# XXX -Xms1024m -XX:NewSize=300m
+. ./setupclasspath.sh
+echo $CP
+$JAVA_HOME/bin/java -cp $CP -Damqj.logging.level="warn" -Damqj.test.logging.level="info" -Dlog4j.configuration=perftests.log4j org.apache.qpid.pingpong.TestPingPublisher $thehosts /test
diff --git a/java/perftests/bin/testPingSubscriber.sh b/java/perftests/bin/testPingSubscriber.sh
new file mode 100755
index 0000000000..7bf17a619d
--- /dev/null
+++ b/java/perftests/bin/testPingSubscriber.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# args supplied: <host:port>
+#
+if [[ $# < 1 ]] ; then
+ echo "usage: ./testPingSubscriber.sh <host details> [<selector>]"
+ exit 1
+fi
+
+thehosts=$1
+shift
+echo $thehosts
+# XXX -Xms1024m -XX:NewSize=300m
+. ./setupclasspath.sh
+echo $CP
+$JAVA_HOME/bin/java -cp $CP -Damqj.logging.level="warn" -Damqj.test.logging.level="debug" -Dlog4j.configuration=perftests.log4j org.apache.qpid.pingpong.TestPingSubscriber $thehosts guest guest /test "$@"
diff --git a/java/perftests/pom.xml b/java/perftests/pom.xml
index 3af906c4ac..9ca30da0ae 100644
--- a/java/perftests/pom.xml
+++ b/java/perftests/pom.xml
@@ -44,12 +44,38 @@
</dependency>
</dependencies>
-<!-- <build>
+ <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
</plugins>
- </build>-->
+ <!-- Include source files in built jar -->
+ <resources>
+ <resource>
+ <targetPath>src/</targetPath>
+ <filtering>false</filtering>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </resource>
+ <resource>
+ <targetPath></targetPath>
+ <filtering>false</filtering>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>perftests.log4j</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
</project>
diff --git a/java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingClient.java b/java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingClient.java
new file mode 100644
index 0000000000..c96f6bd61d
--- /dev/null
+++ b/java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingClient.java
@@ -0,0 +1,138 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.pingpong;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.jms.Session;
+
+import javax.jms.*;
+import java.net.InetAddress;
+
+public class TestPingClient
+{
+ private static final Logger _logger = Logger.getLogger(TestPingClient.class);
+
+ private static class TestPingMessageListener implements MessageListener
+ {
+ public TestPingMessageListener()
+ {
+ }
+
+ long _lastTimestamp = 0L;
+ long _lastTimestampString = 0L;
+
+ public void onMessage(javax.jms.Message message)
+ {
+ if (_logger.isInfoEnabled())
+ {
+ long timestamp = 0L;
+ long timestampString = 0L;
+
+ try
+ {
+ timestamp = message.getLongProperty("timestamp");
+ timestampString = Long.parseLong(message.getStringProperty("timestampString"));
+
+ if (timestampString != timestamp)
+ {
+ _logger.info("Timetamps differ!:\n" +
+ "timestamp:" + timestamp + "\n" +
+ "timestampString:" + timestampString);
+ }
+
+ }
+ catch (JMSException jmse)
+ {
+ //ignore
+ }
+
+ long diff = timestamp - _lastTimestamp;
+ _lastTimestamp = timestamp;
+
+ long stringDiff = timestampString - _lastTimestampString;
+
+ _lastTimestampString = timestampString;
+
+ _logger.info("Ping: T:" + diff + "ms, TS:" + stringDiff);
+
+ // _logger.info(_name + " got message '" + message + "\n");
+ }
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ _logger.setLevel(Level.INFO);
+
+ _logger.info("Starting...");
+
+ if (args.length < 4)
+ {
+ System.out.println("Usage: brokerdetails username password virtual-path [selector] ");
+ System.exit(1);
+ }
+ try
+ {
+ InetAddress address = InetAddress.getLocalHost();
+ AMQConnection con1 = new AMQConnection(args[0], args[1], args[2],
+ address.getHostName(), args[3]);
+
+
+ _logger.info("Connected with URL:" + con1.toURL());
+
+ final org.apache.qpid.jms.Session session1 = (org.apache.qpid.jms.Session)
+ con1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+
+ String selector = null;
+
+ if (args.length == 5)
+ {
+ selector = args[4];
+ _logger.info("Message selector is <" + selector + ">...");
+ }
+ else
+ {
+ _logger.info("Not using message selector");
+ }
+
+
+ Queue q = new AMQQueue("ping");
+
+ MessageConsumer consumer1 = session1.createConsumer(q,
+ 1, false, false, selector);
+
+ consumer1.setMessageListener(new TestPingMessageListener());
+ con1.start();
+ }
+ catch (Throwable t)
+ {
+ System.err.println("Fatal error: " + t);
+ t.printStackTrace();
+ }
+
+ System.out.println("Waiting...");
+ }
+}
+
diff --git a/java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingProducer.java b/java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingProducer.java
new file mode 100644
index 0000000000..cb9154d97b
--- /dev/null
+++ b/java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingProducer.java
@@ -0,0 +1,223 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.pingpong;
+
+import org.apache.log4j.Logger;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.url.URLSyntaxException;
+import org.apache.qpid.client.AMQNoConsumersException;
+import org.apache.qpid.client.BasicMessageProducer;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.jms.MessageProducer;
+import org.apache.qpid.jms.Session;
+
+import javax.jms.*;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * A client that behaves as follows:
+ * <ul><li>Connects to a queue, whose name is specified as a cmd-line argument</li>
+ * <li>Creates a temporary queue</li>
+ * <li>Creates messages containing a property that is the name of the temporary queue</li>
+ * <li>Fires off a message on the original queue and waits for a response on the temporary queue</li>
+ * </ul>
+ */
+public class TestPingProducer implements ExceptionListener
+{
+ private static final Logger _log = Logger.getLogger(TestPingProducer.class);
+
+ private AMQConnection _connection;
+
+
+ private boolean _publish;
+
+ private long SLEEP_TIME = 250L;
+
+// private class CallbackHandler implements MessageListener
+// {
+//
+// private int _actualMessageCount;
+//
+//
+// public void onMessage(Message m)
+// {
+// if (_log.isDebugEnabled())
+// {
+// _log.debug("Message received: " + m);
+// }
+// _actualMessageCount++;
+// if (_actualMessageCount % 1000 == 0)
+// {
+// _log.info("Received message count: " + _actualMessageCount);
+// }
+// }
+// }
+
+ public TestPingProducer(boolean TRANSACTED, String brokerDetails, String clientID,
+ String virtualpath) throws AMQException, URLSyntaxException
+ {
+ try
+ {
+ createConnection(brokerDetails, clientID, virtualpath);
+
+ Session session;
+
+ if (TRANSACTED)
+ {
+ session = (Session) _connection.createSession(true, Session.SESSION_TRANSACTED);
+ }
+ else
+ {
+ session = (Session) _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ }
+
+ String queue = "ping";
+ AMQQueue destination = new AMQQueue(queue);
+ MessageProducer producer = (MessageProducer) session.createProducer(destination);
+
+ _connection.setExceptionListener(this);
+
+ _connection.start();
+
+ while (_publish)
+ {
+/*
+ TextMessage msg = session.createTextMessage(
+ "Presented to in conjunction with Mahnah Mahnah and the Snowths: " + ++messageNumber);
+*/
+ ObjectMessage msg = session.createObjectMessage();
+
+ msg.setStringProperty("timestampString", Long.toString(System.currentTimeMillis()));
+ msg.setLongProperty("timestamp", System.currentTimeMillis());
+
+ ((BasicMessageProducer) producer).send(msg, DeliveryMode.NON_PERSISTENT, true);
+ _log.info("Message Sent.");
+ _log.debug(msg);
+
+
+ if (TRANSACTED)
+ {
+ try
+ {
+ session.commit();
+ _log.debug("Session Commited.");
+ }
+ catch (JMSException e)
+ {
+ _log.trace("JMSException on commit:" + e);
+ try
+ {
+ session.rollback();
+ _log.debug("Message rolled back.");
+ }
+ catch (JMSException jsme)
+ {
+ _log.trace("JMSE on rollback:" + jsme);
+ }
+
+
+ if (e.getLinkedException() instanceof AMQNoConsumersException)
+ {
+ _log.info("No Consumers on queue:'" + queue + "'");
+ continue;
+ }
+ }
+ }
+
+
+ if (SLEEP_TIME > 0)
+ {
+ try
+ {
+ Thread.sleep(SLEEP_TIME);
+ }
+ catch (InterruptedException ie)
+ {
+ //do nothing
+ }
+ }
+
+
+ }
+
+ }
+ catch (JMSException e)
+ {
+ _publish = false;
+ e.printStackTrace();
+ }
+ }
+
+ private void createConnection(String brokerDetails, String clientID, String virtualpath) throws AMQException, URLSyntaxException
+ {
+ _publish = true;
+ _connection = new AMQConnection(brokerDetails, "guest", "guest",
+ clientID, virtualpath);
+ _log.info("Connected with URL:" + _connection.toURL());
+ }
+
+ /**
+ * @param args argument 1 if present specifies the name of the temporary queue to create. Leaving it blank
+ * means the server will allocate a name.
+ */
+ public static void main(String[] args)
+ {
+ if (args.length < 2)
+ {
+ System.err.println("Usage: TestPingPublisher <brokerDetails> <virtual path> [transacted]");
+ System.exit(0);
+ }
+ try
+ {
+ InetAddress address = InetAddress.getLocalHost();
+ String clientID = address.getHostName() + System.currentTimeMillis();
+ new TestPingProducer(args.length == 3, args[0], clientID, args[1]);
+ }
+ catch (UnknownHostException e)
+ {
+ e.printStackTrace();
+ }
+ catch (AMQException e)
+ {
+ System.err.println("Error in client: " + e);
+ e.printStackTrace();
+ }
+ catch (URLSyntaxException e)
+ {
+ System.err.println("Error in connection arguments : " + e);
+ }
+
+ //System.exit(0);
+ }
+
+ /**
+ * @see javax.jms.ExceptionListener#onException(javax.jms.JMSException)
+ */
+ public void onException(JMSException e)
+ {
+ System.err.println(e.getMessage());
+
+ _publish = false;
+ e.printStackTrace(System.err);
+ }
+}
diff --git a/java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingPublisher.java b/java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingPublisher.java
new file mode 100644
index 0000000000..9f66387497
--- /dev/null
+++ b/java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingPublisher.java
@@ -0,0 +1,188 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.pingpong;
+
+import org.apache.log4j.Logger;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.url.URLSyntaxException;
+import org.apache.qpid.client.AMQTopic;
+import org.apache.qpid.client.BasicMessageProducer;
+import org.apache.qpid.jms.MessageProducer;
+import org.apache.qpid.jms.Session;
+
+import javax.jms.*;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * A client that behaves as follows:
+ * <ul><li>Connects to a queue, whose name is specified as a cmd-line argument</li>
+ * <li>Creates a temporary queue</li>
+ * <li>Creates messages containing a property that is the name of the temporary queue</li>
+ * <li>Fires off a message on the original queue and waits for a response on the temporary queue</li>
+ * </ul>
+ */
+public class TestPingPublisher implements ExceptionListener
+{
+ private static final Logger _log = Logger.getLogger(TestPingPublisher.class);
+
+ private AMQConnection _connection;
+
+ private boolean _publish;
+
+ private long SLEEP_TIME = 0L;
+
+// private class CallbackHandler implements MessageListener
+// {
+//
+// private int _actualMessageCount;
+//
+//
+// public void onMessage(Message m)
+// {
+// if (_log.isDebugEnabled())
+// {
+// _log.debug("Message received: " + m);
+// }
+// _actualMessageCount++;
+// if (_actualMessageCount % 1000 == 0)
+// {
+// _log.info("Received message count: " + _actualMessageCount);
+// }
+// }
+// }
+
+ public TestPingPublisher(String brokerDetails, String clientID, String virtualpath) throws AMQException, URLSyntaxException
+ {
+ try
+ {
+ createConnection(brokerDetails, clientID, virtualpath);
+
+ Session session = (Session) _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ //AMQQueue destination = new AMQQueue("ping");
+ AMQTopic destination = new AMQTopic("ping");
+ MessageProducer producer = (MessageProducer) session.createProducer(destination);
+
+ _connection.setExceptionListener(this);
+
+ _connection.start();
+
+ int msgCount = 0;
+ while (_publish)
+ {
+/*
+ TextMessage msg = session.createTextMessage(
+ "Presented to in conjunction with Mahnah Mahnah and the Snowths: " + ++messageNumber);
+*/
+ ObjectMessage msg = session.createObjectMessage();
+
+ Long time = System.nanoTime();
+ msg.setStringProperty("timestampString", Long.toString(time));
+ msg.setLongProperty("timestamp", time);
+
+ ((BasicMessageProducer) producer).send(msg, DeliveryMode.PERSISTENT, true);
+
+ _log.info("Message Sent:" + msgCount++);
+ _log.debug(msg);
+
+ if (msgCount == Integer.MAX_VALUE)
+ {
+ _publish = false;
+ }
+
+ if (SLEEP_TIME > 0)
+ {
+ try
+ {
+ Thread.sleep(SLEEP_TIME);
+ }
+ catch (InterruptedException ie)
+ {
+ //do nothing
+ }
+ }
+
+
+ }
+
+ }
+ catch (JMSException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private void createConnection(String brokerDetails, String clientID, String virtualpath) throws AMQException, URLSyntaxException
+ {
+ _publish = true;
+ _connection = new AMQConnection(brokerDetails, "guest", "guest",
+ clientID, virtualpath);
+
+ _log.info("Connected with URL:" + _connection.toURL());
+ }
+
+ /**
+ * @param args argument 1 if present specifies the name of the temporary queue to create. Leaving it blank
+ * means the server will allocate a name.
+ */
+ public static void main(String[] args)
+ {
+ if (args.length < 2)
+ {
+ System.err.println("Usage: TestPingPublisher <brokerDetails> <virtual path>");
+ System.exit(0);
+ }
+ try
+ {
+ InetAddress address = InetAddress.getLocalHost();
+ String clientID = address.getHostName() + System.currentTimeMillis();
+ new TestPingPublisher(args[0], clientID, args[1]);
+ }
+ catch (UnknownHostException e)
+ {
+ e.printStackTrace();
+ }
+ catch (AMQException e)
+ {
+ System.err.println("Error in client: " + e);
+ e.printStackTrace();
+ }
+ catch (URLSyntaxException e)
+ {
+ System.err.println("Error in connection arguments : " + e);
+ }
+
+ //System.exit(0);
+ }
+
+ /**
+ * @see javax.jms.ExceptionListener#onException(javax.jms.JMSException)
+ */
+ public void onException(JMSException e)
+ {
+ System.err.println(e.getMessage());
+
+ _publish = false;
+ e.printStackTrace(System.err);
+ }
+}
diff --git a/java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingSubscriber.java b/java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingSubscriber.java
new file mode 100644
index 0000000000..001f1e3568
--- /dev/null
+++ b/java/perftests/src/main/java/org/apache/qpid/pingpong/TestPingSubscriber.java
@@ -0,0 +1,134 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.pingpong;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQTopic;
+import org.apache.qpid.jms.Session;
+
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Topic;
+import javax.jms.JMSException;
+import java.net.InetAddress;
+
+public class TestPingSubscriber
+{
+ private static final Logger _logger = Logger.getLogger(TestPingSubscriber.class);
+
+ private static class TestPingMessageListener implements MessageListener
+ {
+ public TestPingMessageListener()
+ {
+ }
+
+ long _lastTimestamp = 0L;
+ long _lastTimestampString = 0L;
+
+ public void onMessage(javax.jms.Message message)
+ {
+ Long time = System.nanoTime();
+
+ if (_logger.isInfoEnabled())
+ {
+ long timestampString = 0L;
+
+ try
+ {
+ long timestamp = message.getLongProperty("timestamp");
+ timestampString = Long.parseLong(message.getStringProperty("timestampString"));
+
+ if (timestampString != timestamp)
+ {
+ _logger.info("Timetamps differ!:\n" +
+ "timestamp:" + timestamp + "\n" +
+ "timestampString:" + timestampString);
+ }
+
+ }
+ catch (JMSException jmse)
+ {
+ // ignore
+ }
+
+
+ long stringDiff = time - timestampString;
+
+ _logger.info("Ping: TS:" + stringDiff / 1000 + "us");
+
+ // _logger.info(_name + " got message '" + message + "\n");
+ }
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ _logger.info("Starting...");
+
+ if (args.length < 4)
+ {
+ System.out.println("Usage: brokerdetails username password virtual-path [selector] ");
+ System.exit(1);
+ }
+ try
+ {
+ InetAddress address = InetAddress.getLocalHost();
+ AMQConnection con1 = new AMQConnection(args[0], args[1], args[2],
+ address.getHostName(), args[3]);
+
+ _logger.info("Connected with URL:" + con1.toURL());
+
+ final org.apache.qpid.jms.Session session1 = (org.apache.qpid.jms.Session)
+ con1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+
+ String selector = null;
+
+ if (args.length == 5)
+ {
+ selector = args[4];
+ _logger.info("Message selector is <" + selector + ">...");
+ }
+ else
+ {
+ _logger.info("Not using message selector ");
+ }
+
+ Topic t = new AMQTopic("ping");
+
+ MessageConsumer consumer1 = session1.createConsumer(t,
+ 1, false, false, selector);
+
+ consumer1.setMessageListener(new TestPingMessageListener());
+ con1.start();
+ }
+ catch (Throwable t)
+ {
+ System.err.println("Fatal error: " + t);
+ t.printStackTrace();
+ }
+
+ System.out.println("Waiting...");
+ }
+}
+
diff --git a/java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceRequestingClient.java b/java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceRequestingClient.java
index b52d06558a..93e2d4685b 100644
--- a/java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceRequestingClient.java
+++ b/java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceRequestingClient.java
@@ -41,7 +41,6 @@ import java.net.UnknownHostException;
* <li>Creates messages containing a property that is the name of the temporary queue</li>
* <li>Fires off a message on the original queue and waits for a response on the temporary queue</li>
* </ul>
- *
*/
public class ServiceRequestingClient implements ExceptionListener
{
@@ -167,6 +166,7 @@ public class ServiceRequestingClient implements ExceptionListener
}
}
}
+
public ServiceRequestingClient(String brokerHosts, String clientID, String username, String password,
String vpath, String commandQueueName,
final int messageCount, final int messageDataLength) throws AMQException, URLSyntaxException
@@ -217,6 +217,7 @@ public class ServiceRequestingClient implements ExceptionListener
/**
* Run the test and notify an object upon receipt of all responses.
+ *
* @param waiter the object that will be notified
* @throws JMSException
*/
@@ -260,6 +261,7 @@ public class ServiceRequestingClient implements ExceptionListener
{
System.err.println(
"Usage: ServiceRequestingClient <brokerDetails - semicolon separated host:port list> <username> <password> <vpath> <command queue name> <number of messages> <message size>");
+ System.exit(1);
}
try
{
@@ -292,7 +294,7 @@ public class ServiceRequestingClient implements ExceptionListener
}
}
- /**
+ /**
* @see javax.jms.ExceptionListener#onException(javax.jms.JMSException)
*/
public void onException(JMSException e)
diff --git a/java/perftests/src/main/java/perftests.log4j b/java/perftests/src/main/java/perftests.log4j
new file mode 100644
index 0000000000..6c74baedf6
--- /dev/null
+++ b/java/perftests/src/main/java/perftests.log4j
@@ -0,0 +1,31 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+log4j.rootLogger=${root.logging.level}
+
+
+log4j.logger.org.apache.qpid=${amqj.logging.level}, console
+log4j.additivity.org.apache.qpid=false
+
+log4j.logger.org.apache.qpid.requestreply=${amqj.test.logging.level}
+log4j.logger.org.apache.qpid.pingpong=${amqj.test.logging.level}
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.Threshold=all
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%t %d %p [%c{4}] %m%n
diff --git a/java/pom.xml b/java/pom.xml
index 759917c7e6..25dba411e5 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -115,6 +115,7 @@
<module>client</module>
<module>cluster</module>
<module>systests</module>
+ <module>perftests</module>
<module>management/eclipse-plugin</module>
</modules>