activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r656379 - in /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf: PerfConsumer.java SimpleDurableTopicTest.java
Date Wed, 14 May 2008 19:37:45 GMT
Author: rajdavies
Date: Wed May 14 12:37:45 2008
New Revision: 656379

URL: http://svn.apache.org/viewvc?rev=656379&view=rev
Log:
Add an optional initial delay for the consumer

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleDurableTopicTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java?rev=656379&r1=656378&r2=656379&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java
Wed May 14 12:37:45 2008
@@ -38,15 +38,17 @@
     protected Connection connection;
     protected MessageConsumer consumer;
     protected long sleepDuration;
+    protected long initialDelay;
     protected boolean enableAudit = false;
     protected ActiveMQMessageAudit audit = new ActiveMQMessageAudit(16 * 1024,20);
+    protected boolean firstMessage =true;
 
     protected PerfRate rate = new PerfRate();
 
     public PerfConsumer(ConnectionFactory fac, Destination dest, String consumerName) throws
JMSException {
         connection = fac.createConnection();
         connection.setClientID(consumerName);
-        Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        Session s = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
         if (dest instanceof Topic && consumerName != null && consumerName.length()
> 0) {
             consumer = s.createDurableSubscriber((Topic)dest, consumerName);
         } else {
@@ -77,6 +79,15 @@
     }
 
     public void onMessage(Message msg) {
+        if (firstMessage) {
+            firstMessage=false;
+            if (getInitialDelay() > 0) {
+                try {
+                    Thread.sleep(getInitialDelay());
+                } catch (InterruptedException e) {
+                }
+            }
+        }
         rate.increment();
         try {
             if (enableAudit && !this.audit.isInOrder(msg.getJMSMessageID())) {
@@ -112,4 +123,18 @@
     public void setEnableAudit(boolean doAudit) {
         this.enableAudit = doAudit;
     }
+
+    /**
+     * @return the initialDelay
+     */
+    public long getInitialDelay() {
+        return initialDelay;
+    }
+
+    /**
+     * @param initialDelay the initialDelay to set
+     */
+    public void setInitialDelay(long initialDelay) {
+        this.initialDelay = initialDelay;
+    }
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleDurableTopicTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleDurableTopicTest.java?rev=656379&r1=656378&r2=656379&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleDurableTopicTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleDurableTopicTest.java
Wed May 14 12:37:45 2008
@@ -28,7 +28,7 @@
     
     protected void setUp() throws Exception {
         numberOfDestinations=1;
-        numberOfConsumers = 4;
+        numberOfConsumers = 1;
         numberofProducers = 1;
         sampleCount=1000;
         playloadSize = 1024;
@@ -41,7 +41,9 @@
     }
 
     protected PerfConsumer createConsumer(ConnectionFactory fac, Destination dest, int number)
throws JMSException {
-        return new PerfConsumer(fac, dest, "subs:" + number);
+        PerfConsumer result = new PerfConsumer(fac, dest, "subs:" + number);
+        result.setInitialDelay(20000);
+        return result;
     }
 
 }



Mime
View raw message