You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2015/10/09 23:42:07 UTC

qpid-jms git commit: QPIDJMS-122 Add a test case for message producer in a TX session.

Repository: qpid-jms
Updated Branches:
  refs/heads/master 4cb77adbd -> f802a36ae


QPIDJMS-122 Add a test case for message producer in a TX session.

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/f802a36a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/f802a36a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/f802a36a

Branch: refs/heads/master
Commit: f802a36ae05697ad4454ab7a40097389cfde365e
Parents: 4cb77ad
Author: Timothy Bish <ta...@gmail.com>
Authored: Fri Oct 9 17:39:15 2015 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Fri Oct 9 17:39:15 2015 -0400

----------------------------------------------------------------------
 .../bench/TransactedProducerSendRateTest.java   | 153 +++++++++++++++++++
 1 file changed, 153 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f802a36a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/bench/TransactedProducerSendRateTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/bench/TransactedProducerSendRateTest.java b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/bench/TransactedProducerSendRateTest.java
new file mode 100644
index 0000000..436dd5e
--- /dev/null
+++ b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/bench/TransactedProducerSendRateTest.java
@@ -0,0 +1,153 @@
+/**
+ * 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.jms.bench;
+
+import java.util.concurrent.TimeUnit;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+import org.apache.activemq.broker.jmx.QueueViewMBean;
+import org.apache.qpid.jms.support.AmqpTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Compares send rate using a TX Session for QPid JMS and ActiveMQ JMS
+ */
+@Ignore
+public class TransactedProducerSendRateTest extends AmqpTestSupport {
+
+    private final int ITERATIONS = 20;
+    private final int BATCH_SIZE = 100;
+
+    @Override
+    protected boolean isAddOpenWireConnector() {
+        return true;
+    }
+
+    @Override
+    protected boolean isFrameTracingEnabled() {
+        return true;
+    }
+
+    @Test
+    public void testSendNonPersistentTopicMessagesAMQP() throws Exception {
+        connection = createAmqpConnection();
+        Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+        Destination destination = session.createTopic(getDestinationName());
+        MessageProducer producer = session.createProducer(destination);
+
+        // Warm
+        produceMessages(session, producer);
+
+        long totalCycleTime = 0;
+        for (int i = 0; i < ITERATIONS; i++) {
+            totalCycleTime += produceMessages(session, producer);
+        }
+
+        long smoothedTime = totalCycleTime / ITERATIONS;
+
+        LOG.info("Total time for QPid client = {}", TimeUnit.NANOSECONDS.toMillis(smoothedTime));
+    }
+
+    @Test
+    public void testSendNonPersistentTopicMessagesOpenWire() throws Exception {
+        connection = createActiveMQConnection();
+        Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+        Destination destination = session.createTopic(getDestinationName());
+        MessageProducer producer = session.createProducer(destination);
+        producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+        // Warm
+        produceMessages(session, producer);
+
+        long totalCycleTime = 0;
+        for (int i = 0; i < ITERATIONS; i++) {
+            totalCycleTime += produceMessages(session, producer);
+        }
+
+        long smoothedTime = totalCycleTime / ITERATIONS;
+
+        LOG.info("Total time for ActiveMQ client = {}", TimeUnit.NANOSECONDS.toMillis(smoothedTime));
+    }
+
+    @Test
+    public void testSendNonPersistentQueueMessagesAMQP() throws Exception {
+        connection = createAmqpConnection();
+        Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+        Destination destination = session.createQueue(getDestinationName());
+        MessageProducer producer = session.createProducer(destination);
+        QueueViewMBean queueView = getProxyToQueue(getDestinationName());
+
+        // Warm
+        produceMessages(session, producer);
+
+        long totalCycleTime = 0;
+        for (int i = 0; i < ITERATIONS; i++) {
+            totalCycleTime += produceMessages(session, producer);
+            queueView.purge();
+        }
+
+        long smoothedTime = totalCycleTime / ITERATIONS;
+
+        LOG.info("Total time for QPid client = {}", TimeUnit.NANOSECONDS.toMillis(smoothedTime));
+    }
+
+    @Test
+    public void testSendNonPersistentQueueMessagesOpenWire() throws Exception {
+        connection = createActiveMQConnection();
+        Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+        Destination destination = session.createQueue(getDestinationName());
+        MessageProducer producer = session.createProducer(destination);
+        producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+        QueueViewMBean queueView = getProxyToQueue(getDestinationName());
+
+        // Warm
+        produceMessages(session, producer);
+
+        long totalCycleTime = 0;
+        for (int i = 0; i < ITERATIONS; i++) {
+            totalCycleTime += produceMessages(session, producer);
+            queueView.purge();
+        }
+
+        long smoothedTime = totalCycleTime / ITERATIONS;
+
+        LOG.info("Total time for ActiveMQ client = {}", TimeUnit.NANOSECONDS.toMillis(smoothedTime));
+    }
+
+    // Send under TX - Count commit in elapsed time.
+    private long produceMessages(Session session, MessageProducer producer) throws Exception {
+        Message message = session.createTextMessage("payload");
+
+        long start = System.nanoTime();
+        for (int i = 0; i < BATCH_SIZE; ++i) {
+            producer.send(message);
+        }
+
+        if (session.getTransacted()) {
+            session.commit();
+        }
+        long elapsed = System.nanoTime() - start;
+
+        return elapsed;
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org