[jboss-cvs] JBoss Messaging SVN: r5041 - in trunk/examples/jms: src/org/jboss/jms/example and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Sep 29 13:47:11 EDT 2008


Author: clebert.suconic at jboss.com
Date: 2008-09-29 13:47:11 -0400 (Mon, 29 Sep 2008)
New Revision: 5041

Modified:
   trunk/examples/jms/build.xml
   trunk/examples/jms/src/org/jboss/jms/example/PerfExample.java
   trunk/examples/jms/src/org/jboss/jms/util/PerfParams.java
Log:
Adding throughput calculation on perfExample

Modified: trunk/examples/jms/build.xml
===================================================================
--- trunk/examples/jms/build.xml	2008-09-29 16:42:39 UTC (rev 5040)
+++ trunk/examples/jms/build.xml	2008-09-29 17:47:11 UTC (rev 5041)
@@ -54,6 +54,7 @@
    <property name="queue.lookup" value="MyQueue"/>
    <property name="cf.lookup" value="ConnectionFactory"/>
    <property name="throttle.rate" value="-1"/>
+   <property name="throughput.queue" value="NONE"/>
 
    <path id="other.system.client.classpath">
        <fileset dir="${other.system.client.dir}">
@@ -152,6 +153,7 @@
 * queue.lookup         ${queue.lookup} (MyQueue)         Queue JNDI lookup               
 * cf.lookup            ${cf.lookup} (ConnectionFactory)  ConnectionFactory JNDI lookup   
 * throttle.rate        ${throttle.rate} (-1)             The max rate to throttle senders to in msgs/sec, -1 = no throttle
+* throughput.queue     ${throughput.queue} (NONE)        The queue used to calculate throughput on consuming messages
 ***********************************************************************************
       </echo>
    </target>
@@ -177,6 +179,7 @@
          <arg value="${queue.lookup}"/>
          <arg value="${cf.lookup}"/>
          <arg value="${throttle.rate}"/>
+         <arg value="${throughput.queue}"/>
       </java>
    </target>
 
@@ -201,6 +204,7 @@
          <arg value="${queue.lookup}"/>
          <arg value="${cf.lookup}"/>
          <arg value="${throttle.rate}"/>
+         <arg value="${throughput.queue}"/>
       </java>
    </target>
 

Modified: trunk/examples/jms/src/org/jboss/jms/example/PerfExample.java
===================================================================
--- trunk/examples/jms/src/org/jboss/jms/example/PerfExample.java	2008-09-29 16:42:39 UTC (rev 5040)
+++ trunk/examples/jms/src/org/jboss/jms/example/PerfExample.java	2008-09-29 17:47:11 UTC (rev 5041)
@@ -59,6 +59,8 @@
    private static Logger log = Logger.getLogger(PerfExample.class);
 
    private Queue queue;
+   
+   private Queue throughputQueue;
 
    private Connection connection;
 
@@ -81,6 +83,7 @@
       String queueLookup = args[9];
       String connectionFactoryLookup = args[10];
       int throttleRate = Integer.parseInt(args[11]);
+      String throughputQueue = args[12];
 
       PerfParams perfParams = new PerfParams();
       perfParams.setNoOfMessagesToSend(noOfMessages);
@@ -94,6 +97,7 @@
       perfParams.setQueueLookup(queueLookup);
       perfParams.setConnectionFactoryLookup(connectionFactoryLookup);
       perfParams.setThrottleRate(throttleRate);
+      perfParams.setThroughputQueue(throughputQueue);
 
       if (args[0].equalsIgnoreCase("-l"))
       {
@@ -107,11 +111,16 @@
 
    private void init(final boolean transacted,
                      final String queueLookup,
+                     final String throughputQueue,
                      final String connectionFactoryLookup,
                      final boolean dupsOk) throws Exception
    {
       InitialContext initialContext = new InitialContext();
       queue = (Queue)initialContext.lookup(queueLookup);
+      if (!throughputQueue.equals("NONE"))
+      {
+         this.throughputQueue = (Queue)initialContext.lookup(throughputQueue);
+      }
       ConnectionFactory cf = (ConnectionFactory)initialContext.lookup(connectionFactoryLookup);
       connection = cf.createConnection();
       session = connection.createSession(transacted, transacted ? Session.SESSION_TRANSACTED
@@ -133,6 +142,7 @@
          log.info("params = " + perfParams);
          init(perfParams.isSessionTransacted(),
               perfParams.getQueueLookup(),
+              perfParams.getThroughputQueue(),
               perfParams.getConnectionFactoryLookup(),
               perfParams.isDupsOk());
          start = System.currentTimeMillis();
@@ -182,11 +192,17 @@
 
    private void displayThrouput(final PerfParams perfParams, final long start) throws JMSException
    {
-      MessageConsumer consumer = session.createConsumer(queue);
+      
+      if (throughputQueue == null)
+      {
+         return;
+      }
+      
+      MessageConsumer consumer = session.createConsumer(throughputQueue);
 
       connection.start();
 
-      Message msg = consumer.receive(10000);
+      Message msg = consumer.receive(60000);
 
       if (perfParams.isSessionTransacted())
       {
@@ -273,8 +289,10 @@
       {
          init(perfParams.isSessionTransacted(),
               perfParams.getQueueLookup(),
+              perfParams.getThroughputQueue(),
               perfParams.getConnectionFactoryLookup(),
               perfParams.isDupsOk());
+         
          MessageConsumer messageConsumer = session.createConsumer(queue);
          connection.start();
 
@@ -323,13 +341,16 @@
 
    private void answerThroughput(final PerfParams perfParams, final long end) throws JMSException
    {
-      MessageProducer producer = session.createProducer(queue);
-      Message msg = session.createMessage();
-      msg.setLongProperty(THROUGHPUT_DATA_PROPERTY_NAME, end);
-      producer.send(msg);
-      if (perfParams.isSessionTransacted())
+      if (throughputQueue != null)
       {
-         session.commit();
+         MessageProducer producer = session.createProducer(throughputQueue);
+         Message msg = session.createMessage();
+         msg.setLongProperty(THROUGHPUT_DATA_PROPERTY_NAME, end);
+         producer.send(msg);
+         if (perfParams.isSessionTransacted())
+         {
+            session.commit();
+         }
       }
    }
 

Modified: trunk/examples/jms/src/org/jboss/jms/util/PerfParams.java
===================================================================
--- trunk/examples/jms/src/org/jboss/jms/util/PerfParams.java	2008-09-29 16:42:39 UTC (rev 5040)
+++ trunk/examples/jms/src/org/jboss/jms/util/PerfParams.java	2008-09-29 17:47:11 UTC (rev 5041)
@@ -46,6 +46,7 @@
    private String connectionFactoryLookup = "/ConnectionFactory";
    private boolean dupsOk;
    private int throttleRate;
+   private String throughputQueue;
 
    public int getNoOfMessagesToSend()
    {
@@ -156,7 +157,17 @@
    {
       this.throttleRate = throttleRate;
    }
+   
+   public String getThroughputQueue()
+   {
+      return throughputQueue;
+   }
 
+   public void setThroughputQueue(String throughputQueue)
+   {
+      this.throughputQueue = throughputQueue;
+   }
+
    public String toString()
    {
       return "message to send = " + noOfMessagesToSend + ", DeliveryMode = " +
@@ -164,7 +175,7 @@
               (isSessionTransacted ? ", transaction batch size = " + transactionBatchSize : "") + ", drain queue = " + drainQueue +
               ", queue lookup = " + queueLookup + ", connection factory lookup = " + connectionFactoryLookup +
               ", Session Acknowledge mode = " + (dupsOk ? "DUPS_OK_ACKNOWLEDGE" : "AUTO_ACKNOWLEDGE") + 
-              ", Throttle rate = " + throttleRate;
+              ", Throttle rate = " + throttleRate + ", throughputQueue = " + throughputQueue;
    }
 
 




More information about the jboss-cvs-commits mailing list