From c99f05529f02f6ee4038ca612155aef4b6f73227 Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Tue, 5 Feb 2008 12:05:52 +0000 Subject: [PATCH] Updated the performance tests git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@618617 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/perf/AMQStoreDurableTopicTest.java | 4 ++-- .../org/apache/activemq/perf/PerfConsumer.java | 12 ++++++++++-- .../org/apache/activemq/perf/PerfProducer.java | 4 ++++ .../perf/SimpleNonPersistentQueueTest.java | 1 + .../org/apache/activemq/perf/SimpleQueueTest.java | 15 ++++++++++++--- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreDurableTopicTest.java b/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreDurableTopicTest.java index ca50a68d55..ab258a5137 100644 --- a/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreDurableTopicTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreDurableTopicTest.java @@ -38,8 +38,8 @@ public class AMQStoreDurableTopicTest extends SimpleDurableTopicTest { } protected void setUp() throws Exception { - numberofProducers=2; - numberOfConsumers=10; + numberofProducers=1; + numberOfConsumers=1; this.consumerSleepDuration=0; super.setUp(); } diff --git a/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java b/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java index 9f7cd58961..478eb9e0b7 100644 --- a/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java +++ b/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java @@ -26,7 +26,6 @@ import javax.jms.MessageListener; import javax.jms.Session; import javax.jms.Topic; -import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQMessageAudit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -39,6 +38,7 @@ public class PerfConsumer implements MessageListener { protected Connection connection; protected MessageConsumer consumer; protected long sleepDuration; + protected boolean enableAudit = true; protected ActiveMQMessageAudit audit = new ActiveMQMessageAudit(16 * 1024,20); protected PerfRate rate = new PerfRate(); @@ -79,7 +79,7 @@ public class PerfConsumer implements MessageListener { public void onMessage(Message msg) { rate.increment(); try { - if (msg.getJMSDestination() instanceof Topic && !this.audit.isInOrder(msg.getJMSMessageID())) { + if (enableAudit && !this.audit.isInOrder(msg.getJMSMessageID())) { LOG.error("Message out of order!!" + msg); } if (this.audit.isDuplicate(msg)){ @@ -104,4 +104,12 @@ public class PerfConsumer implements MessageListener { public synchronized void setSleepDuration(long sleepDuration) { this.sleepDuration = sleepDuration; } + + public boolean isEnableAudit() { + return enableAudit; + } + + public void setEnableAudit(boolean doAudit) { + this.enableAudit = doAudit; + } } diff --git a/activemq-core/src/test/java/org/apache/activemq/perf/PerfProducer.java b/activemq-core/src/test/java/org/apache/activemq/perf/PerfProducer.java index 493551f39b..d59f8c4557 100644 --- a/activemq-core/src/test/java/org/apache/activemq/perf/PerfProducer.java +++ b/activemq-core/src/test/java/org/apache/activemq/perf/PerfProducer.java @@ -49,6 +49,10 @@ public class PerfProducer implements Runnable { public void setDeliveryMode(int mode) throws JMSException { producer.setDeliveryMode(mode); } + + public void setTimeToLive(int ttl) throws JMSException { + producer.setTimeToLive(ttl); + } public void shutDown() throws JMSException { connection.close(); diff --git a/activemq-core/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueTest.java b/activemq-core/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueTest.java index ea2a6b4b59..13d489d95b 100644 --- a/activemq-core/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueTest.java @@ -29,6 +29,7 @@ public class SimpleNonPersistentQueueTest extends SimpleQueueTest { protected PerfProducer createProducer(ConnectionFactory fac, Destination dest, int number, byte[] payload) throws JMSException { PerfProducer pp = new PerfProducer(fac, dest, payload); pp.setDeliveryMode(DeliveryMode.NON_PERSISTENT); + pp.setTimeToLive(100); return pp; } } diff --git a/activemq-core/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java b/activemq-core/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java index cf98b4e0c2..3ae95d5a58 100644 --- a/activemq-core/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java @@ -16,6 +16,7 @@ */ package org.apache.activemq.perf; +import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Session; @@ -30,10 +31,18 @@ public class SimpleQueueTest extends SimpleTopicTest { } protected void setUp() throws Exception { - numberOfConsumers = 10; - numberofProducers = 10; - this.consumerSleepDuration=20; + numberOfConsumers = 1; + numberofProducers = 2; + this.consumerSleepDuration=0; super.setUp(); } + + protected PerfConsumer createConsumer(ConnectionFactory fac, Destination dest, int number) throws JMSException { + PerfConsumer consumer = new PerfConsumer(fac, dest); + boolean enableAudit = numberOfConsumers <= 1; + System.out.println("Enable Audit = " + enableAudit); + consumer.setEnableAudit(enableAudit); + return consumer; + } }