jMeter - JMS Topic Test Plan

Building a JMS Topic Test Plan

Now let us write a JMeter test plan to test a JMS Provider. We will create one subscriber and one publisher. We will create one thread group and set each one to two iterations
First let us start the JMeter from /home/manisha/apache-jmeter2.9/bin/jmeter.sh..

Add Users

Now create a Thread group as follows −
  • Right-click the Test Plan
  • Select Add > Threads (Users) > Thread Group. Thread Group will get added under the Test Plan node.
  • Rename this Thread Group as JMS pub-sub user.
Thread Group Added
We will change the Loop Count to two. Rest of the default properties of the Thread Group are retained. It means one thread group with one thread or one user sends two messages each through a request queue.

Adding JMS Subscriber and Publisher

Let us see how to add subscribers and publishers −
Add Publisher
  • Add the sampler JMS Publisher to the Publisher element by selecting Add > Sampler > JMS Publisher.
  • Select the JMS Publisher element in the tree.
  • Edit the following properties −
PropertyValueDescription
NameSample PublisherDescriptive name for this element that is shown in the tree.
If the JMS provider uses the jndi.properties filecheck the boxUse jndi.properties. Note that the file must be on the classpath − e.g. by updating the user.classpath JMeter property. If this option is not selected, JMeter uses the "JNDI Initial Context Factory" and "Provider URL" fields to create the connection.
InitialContextFactoryorg apache activemq jndi Active MQInitial Context FactoryName of the context factory.
Provider URLtcp://localhost:61616The URL for the jms provider.
Connection FactoryConnectionFactoryThe URL for the JMS provider.
DestinationdynamicTopics/MyStaticTopic1The name of the message topic. For ActiveMQ Dynamic Topics (create topics dynamically).
Number of samples to aggregate2Number of samples to aggregate.
Message sourceTextareaWhere to obtain the message −
From File − means the referenced file will be read and reused by all samples.
Random File from folder − means a random file will be selected from the folder specified, this folder must contain either files with extension .dat for Bytes Messages, or files with extension .txt or .obj for Object or Text messages
Text area − The Message to use either for Text or Object message
Message typeTextText, Map, Object message or Bytes Message
Rest of properties are retained with the default values. The following screenshot shows the above configurations −
JMS publisher sampler
Add Subscriber
Now that we have defined our users, it is time to define the tasks that they will be performing.
  • Add the sampler JMS Subscriber to the Subscribers element by selecting Add > Sampler > JMS Subscriber.
  • Select the JMS Subscriber element in the tree
  • Edit the following properties −
PropertyValueDescription
NameSample SubscriberDescriptive name for this element that is shown in the tree.
If the JMS provider uses the jndi.properties filecheck the boxUse jndi.properties. Note that the file must be on the classpath − e.g. by updating the user.classpath JMeter property. If this option is not selected, JMeter uses the "JNDI Initial Context Factory" and "Provider URL" fields to create the connection.
InitialContextFactoryorg apache activemq jndi Active MQInitial Context FactoryName of the context factory.
Provider URLtcp://localhost:61616The URL for the JMS provider.
Connection FactoryConnectionFactoryThe URL for the JMS provider.
DestinationdynamicTopics/MyStaticTopic1The name of the message topic. For ActiveMQ Dynamic Topics (create topics dynamically).
Read responseCheck BoxThe sampler should read the response. If not, only the response length is returned.
Timeout2000The timeout to be applied, in milliseconds. 0=none. This is the overall aggregate timeout, not per sample.
Rest of the properties are retained with the default values. The following screenshot shows the above configurations −
JMS subscriber sampler

Create Listener

Now add the Listener element. This element is responsible for storing all the results of your JMS requests in a file and presenting a visual model of the data.
  • Select the Thread Group element.
  • Add a View Results Tree listener by selecting Add > Listener > View Results Tree.
JMS Pub Sub Test Listener

Save and Execute Test Plan

Now save the above test plan as jms_pub_sub.jmx. Execute this test plan using Run > Start option.

Verify the Output

Output for Publisher
JMS Publish Sub Test Output1JMS Publish Sub Test Output2
Output for Subscriber
JMS Publish Sub Test Output3JMS Publish Sub Test Output4JMS Publish Sub Test Output5
Return to the admin console of ActiveMQ. Here we can see the message status in the topics.
JMS Publish Sub Admin Console