You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2011/02/24 23:28:15 UTC

svn commit: r1074325 - in /activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool: JmsConsumerClient.java JmsProducerClient.java properties/JmsConsumerProperties.java properties/JmsProducerProperties.java

Author: tabish
Date: Thu Feb 24 22:28:15 2011
New Revision: 1074325

URL: http://svn.apache.org/viewvc?rev=1074325&view=rev
Log:
Apply patch for: https://issues.apache.org/jira/browse/AMQ-3186

Modified:
    activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerClient.java
    activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java
    activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsConsumerProperties.java
    activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsProducerProperties.java

Modified: activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerClient.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerClient.java?rev=1074325&r1=1074324&r2=1074325&view=diff
==============================================================================
--- activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerClient.java (original)
+++ activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerClient.java Thu Feb 24 22:28:15 2011
@@ -85,6 +85,7 @@ public class JmsConsumerClient extends A
             while (System.currentTimeMillis() < endTime) {
                 getJmsConsumer().receive();
                 incThroughput();
+                sleep();
             }
         } finally {
             if (client.isDurable() && client.isUnsubscribe()) {
@@ -110,6 +111,7 @@ public class JmsConsumerClient extends A
                 getJmsConsumer().receive();
                 incThroughput();
                 recvCount++;
+                sleep();
             }
         } finally {
             if (client.isDurable() && client.isUnsubscribe()) {
@@ -129,6 +131,7 @@ public class JmsConsumerClient extends A
         getJmsConsumer().setMessageListener(new MessageListener() {
             public void onMessage(Message msg) {
                 incThroughput();
+                sleep();
             }
         });
 
@@ -236,4 +239,15 @@ public class JmsConsumerClient extends A
     public void setClient(JmsClientProperties clientProps) {
         client = (JmsConsumerProperties)clientProps;
     }
+    
+    protected void sleep() {
+        if (client.getRecvDelay() > 0) {
+        	try {
+        		LOG.trace("Sleeping for " + client.getRecvDelay() + " milliseconds");
+        		Thread.sleep(client.getRecvDelay());
+        	} catch (java.lang.InterruptedException ex) {
+        		LOG.warn(ex.getMessage());
+        	}
+        }
+    }
 }

Modified: activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java?rev=1074325&r1=1074324&r2=1074325&view=diff
==============================================================================
--- activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java (original)
+++ activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java Thu Feb 24 22:28:15 2011
@@ -95,6 +95,7 @@ public class JmsProducerClient extends A
                         for (int j = 0; j < dest.length; j++) {
                             getJmsProducer().send(dest[j], getJmsTextMessage());
                             incThroughput();
+                            sleep();
                         }
                     }
                     // Send to only one actual destination
@@ -102,6 +103,7 @@ public class JmsProducerClient extends A
                     for (int i = 0; i < messageCount; i++) {
                         getJmsProducer().send(getJmsTextMessage());
                         incThroughput();
+                        sleep();
                     }
                 }
 
@@ -115,6 +117,7 @@ public class JmsProducerClient extends A
                         for (int j = 0; j < dest.length; j++) {
                             getJmsProducer().send(dest[j], createJmsTextMessage("Text Message [" + i + "]"));
                             incThroughput();
+                            sleep();
                         }
                     }
 
@@ -123,6 +126,7 @@ public class JmsProducerClient extends A
                     for (int i = 0; i < messageCount; i++) {
                         getJmsProducer().send(createJmsTextMessage("Text Message [" + i + "]"));
                         incThroughput();
+                        sleep();
                     }
                 }
             }
@@ -162,6 +166,7 @@ public class JmsProducerClient extends A
                         for (int j = 0; j < dest.length; j++) {
                             getJmsProducer().send(dest[j], getJmsTextMessage());
                             incThroughput();
+                            sleep();
                         }
                     }
                     // Send to only one actual destination
@@ -169,6 +174,7 @@ public class JmsProducerClient extends A
                     while (System.currentTimeMillis() < endTime) {
                         getJmsProducer().send(getJmsTextMessage());
                         incThroughput();
+                        sleep();
                     }
                 }
 
@@ -183,6 +189,7 @@ public class JmsProducerClient extends A
                         for (int j = 0; j < dest.length; j++) {
                             getJmsProducer().send(dest[j], createJmsTextMessage("Text Message [" + count++ + "]"));
                             incThroughput();
+                            sleep();
                         }
                     }
 
@@ -192,6 +199,7 @@ public class JmsProducerClient extends A
 
                         getJmsProducer().send(createJmsTextMessage("Text Message [" + count++ + "]"));
                         incThroughput();
+                        sleep();
                     }
                 }
             }
@@ -265,4 +273,15 @@ public class JmsProducerClient extends A
         Arrays.fill(data, (byte) 0);
         return text + new String(data);
     }
+    
+    protected void sleep() {
+        if (client.getSendDelay() > 0) {
+        	try {
+        		LOG.trace("Sleeping for " + client.getSendDelay() + " milliseconds");
+        		Thread.sleep(client.getSendDelay());
+        	} catch (java.lang.InterruptedException ex) {
+        		LOG.warn(ex.getMessage());
+        	}
+        }
+    }
 }

Modified: activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsConsumerProperties.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsConsumerProperties.java?rev=1074325&r1=1074324&r2=1074325&view=diff
==============================================================================
--- activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsConsumerProperties.java (original)
+++ activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsConsumerProperties.java Thu Feb 24 22:28:15 2011
@@ -26,6 +26,7 @@ public class JmsConsumerProperties exten
 
     protected long recvCount    = 1000000;       // Receive a million messages by default
     protected long recvDuration = 5 * 60 * 1000; // Receive for 5 mins by default
+    protected long recvDelay = 0; // delay in milliseconds for processing received msg 
     protected String recvType   = TIME_BASED_RECEIVING;
 
     public boolean isDurable() {
@@ -75,4 +76,12 @@ public class JmsConsumerProperties exten
     public void setRecvType(String recvType) {
         this.recvType = recvType;
     }
+    
+    public void setRecvDelay(long delay) {
+    	this.recvDelay = delay;
+    }
+    
+    public long getRecvDelay() {
+    	return this.recvDelay;
+    }
 }

Modified: activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsProducerProperties.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsProducerProperties.java?rev=1074325&r1=1074324&r2=1074325&view=diff
==============================================================================
--- activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsProducerProperties.java (original)
+++ activemq/trunk/activemq-tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsProducerProperties.java Thu Feb 24 22:28:15 2011
@@ -27,6 +27,8 @@ public class JmsProducerProperties exten
     protected long sendCount  = 1000000; // Send a million messages by default
     protected long sendDuration = 5 * 60 * 1000; // Send for 5 mins by default
     protected String sendType = TIME_BASED_SENDING;
+    protected long sendDelay = 0;  // delay in milliseconds between each producer send
+    
     // If true, create a different message on each send, otherwise reuse.
     protected boolean createNewMsg; 
 
@@ -77,4 +79,12 @@ public class JmsProducerProperties exten
     public void setCreateNewMsg(boolean createNewMsg) {
         this.createNewMsg = createNewMsg;
     }
+    
+    public void setSendDelay(long delay) {
+    	this.sendDelay = delay;
+    }
+    
+    public long getSendDelay() {
+    	return this.sendDelay;
+    }
 }