Tuesday, May 15, 2012

Testing ActiveMQ with JMeter

For testing ActiveMQ using JMeter, the JMeter site has some useful info.  Here's one particular version of this with some extra detail (well a little :)

One important piece of info: running these tests required ActiveMQ-all-5.4.0.jar or older due to dependencies on a prefetchQueue class which newer jars don't have.  Something in the jmeter set up for JMS, I guess although I haven't looked into it.  The ActiveMQ site should have older versions of ActiveMQ available - grab it and grab the needed jar.  On the day I went, they'd deleted all of their older versions, but I was able to find a copy via a maven repository online (and downloaded from there). Click on the image for a better view.

Start up JMeter. In the test plan, add a Thread Group (I've called it Subscribers): Add -> Threads(users) -> ThreadGroup.  Then on Subscribers add a Sampler->JMS Subscriber and configure the JMS Subscriber similar to below.

Here is the test subscriber set up:
Initial Connection Factory: org.apache.activemq.jndi.ActiveMQInitialContextFactory
Provider URL: tcp://localhost:61616 (obviously, this can vary)
Connection factory: ConnectionFactory
Destination: dynamicQueues/MyQ4  (this requires the magic name 'dynamicQueues/' as a prefix. Obvious? No, it's not.  For Topics use dynamicTopics/)
Number of sample to aggregate: 10 (aggregate them otherwise they'll arrive too fast to deal with them)
Timout (ms): 1000 - set to something otherwise the subscriber will sit waiting for a message

I'll upload the jmx file that backs these tests for ease of use.

To set up the Publisher, it is much the same - new ThreadGroup (renamed Publisher here), then new Sampler JMS Publisher and filling in the fields with similar/identical values although you do get to configure the type of message. Click on image for a better view.

Don't forget to add a Listener -> Graph Results to see a little output and turn on Log Viewer under Options for extra info.  Press the green button to run and check your ActiveMQ for traffic.

Here is the text of the jmx file - start JMeter and read it in to get started: http://www.randomparallels.com/2012/05/jmeter-test-file-for-activemq.html


No comments:

Post a Comment