[jboss-cvs] JBoss Messaging SVN: r4222 - in trunk: examples/jms and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri May 16 11:51:18 EDT 2008
Author: clebert.suconic at jboss.com
Date: 2008-05-16 11:51:17 -0400 (Fri, 16 May 2008)
New Revision: 4222
Modified:
trunk/.classpath
trunk/examples/jms/build.xml
trunk/examples/jms/src/org/jboss/jms/example/PerfExample.java
Log:
Changing parameters on perf example
Modified: trunk/.classpath
===================================================================
--- trunk/.classpath 2008-05-16 15:36:18 UTC (rev 4221)
+++ trunk/.classpath 2008-05-16 15:51:17 UTC (rev 4222)
@@ -1,14 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/.svn/**/*" kind="src" path="src/main"/>
+ <classpathentry kind="src" path="tests/config"/>
+ <classpathentry kind="src" path="src/config"/>
<classpathentry kind="src" path="examples/jms/src"/>
<classpathentry kind="src" path="examples/messaging/src"/>
<classpathentry kind="src" path="build/src"/>
<classpathentry excluding="**/.svn/**/*" kind="src" path="tests/src"/>
- <classpathentry excluding="ide/" kind="src" path="tests/etc"/>
- <classpathentry kind="src" path="src/etc"/>
<classpathentry kind="src" path="tests/jms-tests/src"/>
- <classpathentry kind="src" path="tests/jms-tests/etc"/>
<classpathentry kind="lib" path="thirdparty/oswego-concurrent/lib/concurrent.jar"/>
<classpathentry kind="lib" path="thirdparty/jgroups/lib/jgroups.jar"/>
<classpathentry kind="lib" path="thirdparty/apache-log4j/lib/log4j.jar"/>
Modified: trunk/examples/jms/build.xml
===================================================================
--- trunk/examples/jms/build.xml 2008-05-16 15:36:18 UTC (rev 4221)
+++ trunk/examples/jms/build.xml 2008-05-16 15:51:17 UTC (rev 4222)
@@ -109,22 +109,23 @@
<classpath refid="runtime.classpath"/>
<jvmarg value="-Xmx1024M"/>
<jvmarg value="-XX:+UseParallelGC"/>
- <arg value="-l"/>
+ <arg value="-l"/>
+ <arg value="${message.count}"/>
</java>
</target>
<target name="perfSender" depends="compile">
- <echo>*****************************************************************</echo>
- <echo>* available parameters (-Dmessage.count=1000) *</echo>
- <echo>* *</echo>
- <echo>* param description default *</echo>
- <echo>* message.count number of messages 200000 *</echo>
- <echo>* delivery.mode PERSISTENT/NON_PERSISTENT NON_PERSISTENT *</echo>
- <echo>* sample.period timing period in seconds 1 second *</echo>
- <echo>* sess.trans Is session transacted false *</echo>
- <echo>* sess.trans.size batch size to commit 5000 *</echo>
- <echo>*****************************************************************</echo>
+ <echo>***********************************************************************************</echo>
+ <echo>* available parameters (-Dmessage.count=1000) </echo>
+ <echo>* </echo>
+ <echo>* param description default current</echo>
+ <echo>* message.count number of messages 200000 ${message.count}</echo>
+ <echo>* delivery.mode PERSISTENT/NON_PERSISTENT NON_PERSISTENT ${delivery.mode}</echo>
+ <echo>* sample.period timing period in seconds 1 second ${sample.period}</echo>
+ <echo>* sess.trans Is session transacted false ${sess.trans}</echo>
+ <echo>* sess.trans.size batch size to commit 5000 ${sess.trans.size}</echo>
+ <echo>***********************************************************************************</echo>
<java classname="org.jboss.jms.example.PerfExample" fork="true">
<classpath refid="runtime.classpath"/>
<jvmarg value="-Xmx512M"/>
Modified: trunk/examples/jms/src/org/jboss/jms/example/PerfExample.java
===================================================================
--- trunk/examples/jms/src/org/jboss/jms/example/PerfExample.java 2008-05-16 15:36:18 UTC (rev 4221)
+++ trunk/examples/jms/src/org/jboss/jms/example/PerfExample.java 2008-05-16 15:51:17 UTC (rev 4222)
@@ -34,6 +34,7 @@
*
* @author <a href="ataylor at redhat.com">Andy Taylor</a>
* @author <a href="tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="clebert.suconic at jboss.com">Clebert Suconic</a>
*/
public class PerfExample
{
@@ -50,7 +51,8 @@
PerfExample perfExample = new PerfExample();
if (args[0].equalsIgnoreCase("-l"))
{
- perfExample.runListener();
+ int noOfMessages = Integer.parseInt(args[1]);
+ perfExample.runListener(noOfMessages);
}
else
{
@@ -94,9 +96,6 @@
producer.setDisableMessageID(true);
producer.setDisableMessageTimestamp(true);
producer.setDeliveryMode(perfParams.getDeliveryMode());
- ObjectMessage m = session.createObjectMessage();
- m.setObject(perfParams);
- producer.send(m);
scheduler.scheduleAtFixedRate(command, perfParams.getSamplePeriod(), perfParams.getSamplePeriod(), TimeUnit.SECONDS);
BytesMessage bytesMessage = session.createBytesMessage();
byte[] payload = new byte[1024];
@@ -144,10 +143,11 @@
}
}
- public void runListener()
+ public void runListener(int numberOfMessages)
{
try
{
+ System.out.println("Running listener for " + numberOfMessages);
init(false);
MessageConsumer messageConsumer = session.createConsumer(queue);
CountDownLatch countDownLatch = new CountDownLatch(1);
@@ -161,7 +161,7 @@
break;
}
}
- messageConsumer.setMessageListener(new PerfListener(countDownLatch));
+ messageConsumer.setMessageListener(new PerfListener(countDownLatch, numberOfMessages));
log.info("READY!!!");
countDownLatch.await();
@@ -191,15 +191,16 @@
*/
class PerfListener implements MessageListener
{
- private boolean started = false;
- private PerfParams params = null;
- int count = 0;
private CountDownLatch countDownLatch;
+ int noOfMessages;
+
+ boolean started = false;
- public PerfListener(CountDownLatch countDownLatch)
+ public PerfListener(CountDownLatch countDownLatch, int noOfMessages)
{
this.countDownLatch = countDownLatch;
+ this.noOfMessages = noOfMessages;
}
public void onMessage(Message message)
@@ -207,37 +208,25 @@
if (!started)
{
started = true;
- ObjectMessage m = (ObjectMessage) message;
- try
- {
- params = (PerfParams) m.getObject();
- }
- catch (JMSException e)
- {
- params = new PerfParams();
- }
- log.info("params = " + params);
- scheduler.scheduleAtFixedRate(command, params.getSamplePeriod(), params.getSamplePeriod(), TimeUnit.SECONDS);
+ scheduler.scheduleAtFixedRate(command, 1, 1, TimeUnit.SECONDS);
}
- else
+
+ try
{
- try
+ BytesMessage bm = (BytesMessage) message;
+ messageCount++;
+ if (messageCount == noOfMessages)
{
- BytesMessage bm = (BytesMessage) message;
- messageCount++;
- if (messageCount == params.getNoOfMessagesToSend())
- {
- countDownLatch.countDown();
- scheduler.shutdownNow();
- log.info("average " + command.getAverage() + " per " + (params.getSamplePeriod()/1000) + " secs" );
- }
+ countDownLatch.countDown();
+ scheduler.shutdownNow();
+ log.info("average " + command.getAverage() + " per sec" );
}
- catch (Exception e)
- {
- e.printStackTrace();
- }
}
- }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
}
/**
More information about the jboss-cvs-commits
mailing list