activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r631665 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/NetworkLoadTest.java
Date Wed, 27 Feb 2008 18:07:56 GMT
Author: chirino
Date: Wed Feb 27 10:07:46 2008
New Revision: 631665

URL: http://svn.apache.org/viewvc?rev=631665&view=rev
Log:
Better qos options on the producer of this test.

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/NetworkLoadTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/NetworkLoadTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/NetworkLoadTest.java?rev=631665&r1=631664&r2=631665&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/NetworkLoadTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/NetworkLoadTest.java
Wed Feb 27 10:07:46 2008
@@ -18,12 +18,14 @@
 
 import java.net.URI;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 
 import javax.jms.Connection;
+import javax.jms.DeliveryMode;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
@@ -68,6 +70,7 @@
     // Slower machines might need to make this bigger.
     private static final long SAMPLE_DURATION = Integer.parseInt(System.getProperty("SAMPLES_DURATION",
"" + 1000 * 1));
 	protected static final int BROKER_COUNT = 10;
+	protected static final int MESSAGE_SIZE = 2000;
 
 	class ForwardingClient {
 
@@ -79,21 +82,22 @@
 			toConnection = createConnection(to);
 			Session toSession = toConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 			final MessageProducer producer = toSession.createProducer(new ActiveMQQueue("Q"+to));
-			
+			producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+			producer.setDisableMessageID(true);
+
 			fromConnection = createConnection(from);
 			Session fromSession = fromConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 			MessageConsumer consumer = fromSession.createConsumer(new ActiveMQQueue("Q"+from));
 			
-			
 			consumer.setMessageListener(new MessageListener() {
-				public void onMessage(Message msg) {
-					try {
-						producer.send(msg);
-						forwardCounter.incrementAndGet();
-					} catch (JMSException e) {
-						// this is caused by the connection getting closed. 
+					public void onMessage(Message msg) {
+						try {
+							producer.send(msg);
+							forwardCounter.incrementAndGet();
+						} catch (JMSException e) {
+							// this is caused by the connection getting closed. 
+						}
 					}
-				}
 			});
 		}
 
@@ -115,6 +119,7 @@
 
 	private BrokerService[] brokers;
 	private ForwardingClient[] forwardingClients;
+
 	
 	protected void setUp() throws Exception {
 		brokers = new BrokerService[BROKER_COUNT];
@@ -249,9 +254,11 @@
 					toConnection.start();
 					Session toSession = toConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 					final MessageProducer producer = toSession.createProducer(new ActiveMQQueue("Q"+to));
+					producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+					producer.setDisableMessageID(true);
 
 					for (int i = 0; !done.get(); i++) {
-						TextMessage msg = toSession.createTextMessage("test msg: " + i);
+						TextMessage msg = toSession.createTextMessage(createMessageText(i));
 						producer.send(msg);
 						producedMessages.incrementAndGet();
 					}
@@ -259,11 +266,25 @@
 					e.printStackTrace();
 				}
 			}
+			
+		    private String createMessageText(int index) {
+				StringBuffer buffer = new StringBuffer(MESSAGE_SIZE);
+				buffer.append(index + " on " + new Date() + " ...");
+				if (buffer.length() > MESSAGE_SIZE) {
+					return buffer.substring(0, MESSAGE_SIZE);
+				}
+				for (int i = buffer.length(); i < MESSAGE_SIZE; i++) {
+					buffer.append(' ');
+				}
+
+				return buffer.toString();
+			}
 		};
 		producer.start();
 	
 		
-		// Give the forwarding clients a chance to get going and fill the down stream broker queues..
+		// Give the forwarding clients a chance to get going and fill the down
+		// stream broker queues..
 		Thread.sleep(BROKER_COUNT*200);
 		
         for (int i = 0; i < SAMPLES; i++) {



Mime
View raw message