Skip to main content

Using JMeter with WebSphere MQ

Ronald van de Kuil (ronald.van.de.kuil@nl.ibm.com), Advisory IT Specialist, IBM
Ronald van de Kuil has been working for IBM since 1998. He has experience with java in contact centre environments. Lately Ronald has delved into J2EE programming. You can contact Ronald at ronald.van.de.kuil@nl.ibm.com.
Dick Sol (dick_sol@nl.ibm.com), Advisory IT Specialist, IBM
Dick Sol has been working for IBM since 1998. He has experience with ZLinux, WebSphere Application Developer, Lotus Domino/Notes, Oracle Applications, HR Access and Java. You can contact Dick at dick_sol@nl.ibm.com.

Summary:  This article shows how to send messages from JMeter to WebSphere MQ, which can help you automate your testing, for example, by enabling you to insert messages into MQ using JMS.

Date:  20 Aug 2008
Level:  Intermediate
Activity:  1118 views

Introduction

JMeter is frequently used to automate Web site testing, and it can send messages over JMS. This article shows you how to send messages from JMeter to IBM® WebSphere® MQ. This knowledge can help you automate your testing, for example, by enabling you to insert messages into MQ using JMS. WebSphere MQ can then process these messages and expose them through a Web service or an HTML page. With the JMS request, you can test a complete flow without human intervention, as well as schedule tests automatically and collect the results of the test into HTML reports. How does this process work? Here is an overview of the procedure and the tasks involved:


Figure 1
Figure 1
  1. Set up WebSphere MQ with a queue manager and queue.
  2. Create a JNDI bindings file that describes the queue manager and queue and their JMS names. You do this by making JMSAdmin process a file that contains specific definitions for this purpose -- a one-time action. The JNDI bindings file describes MQ and resides permanently on the file system.
  3. Configure JMeter to use the JMS names and retrieve the connection details from the JNDI bindings file.
  4. When JMeter starts, it retrieves the MQ details from the JNDI repository. These details instruct JMeter to create and configure a queue connection factory, which is implemented by the WebSphere MQ Java library. JMeter will then send messages to MQ using point-to-point messaging.

Create a queue manager and queue in WebSphere MQ

This article uses WebSphere MQ V6, installed in the directory C:\IBM\MQ. Create the following objects in WebSphere MQ using the MQ Explorer:

  • queuemanager QMGR on TCP Port 1416
  • queue SAMPLE.QUEUE

Normally, the first queue manager that you create will listen on Port 1414. You can choose your own Port, but remember to modify the rest of the configuration of the JMS definitions file accordingly. Here is the queue manager and queue that were created:


Figure 2
Figure 2

MQ -- Additional required libraries

Put the following JAR files into the java\lib directory of your MQ installation:

JARObtained via

mqcontext.jar

SupportPac ME01

com.ibm.mq.pcf-6.0.3.jar

SupportPac MS03


Create a JNDI repository for accessing MQ. You can locate the JMSAdmin utility in the java/bin directory of your MQ installation. Configure JMSAdmin to use a directory on the file system to store its JNDI configuration. You can use different mechanisms, but you will have to modify the configuration of JMeter later. Contents of the JMSAdmin.conf file:

C:\IBM\MQ\Java\bin>cat JMSAdmin.config
# ------------------------------------------------------------
# JMSAdmin.config
# ------------------------------------------------------------
INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
PROVIDER_URL=file:../JNDI

Create JMSAdmin.conf using a text editor such as Notepad. The simplest thing is to replace the content of the JMSAdmin.conf file with the content in this article. Of course, you can implement your own JNDI repository, but you will need to configure JMeter accordingly.

Using a text editor, create the file jms_1416.scp, which will be used to insert JDNI key value pairs into the JNDI repository. This file defines the mapping of JMS names to existing objects in the MQ installation. For example, queue connection factory SampleQCF maps to queue manager QMGR on Port 1416. It will access this queue manager over TCP as a client, and not via shared memory.

C:\IBM\MQ\Java\bin>cat jms_1416.scp
#-----------------------------------------------------------------
						
# Delete queue connection factory
DELETEQCF(SampleQCF)
			
# define queue Connection Factory on the default queue manager
DEFINE QCF(SampleQCF) qmgr(QMGR) tran(client) chan(SYSTEM.DEF.SVRCONN) +
host(localhost) port(1416)
						
DISPLAY QCF(SampleQCF)
						
#-----------------------------------------------------------------
# Delete the Queue if it exists
DELETEQ(SampleQueue)

# Define the Queue
DEFINE Q(SampleQueue) qmgr(QMGR) qu(SAMPLE.QUEUE)				

# Display the resulting Queue definition
DISPLAY Q(SampleQueue)						
						
#-----------------------------------------------------------------
# E N D   O F   J N D I   D E F I N I T I O N S
#-----------------------------------------------------------------
end

Create the JNDI bindings file

C:\IBM\MQ\Java\bin>JMSAdmin.bat -v < jms_1416.scp

Start JMSAdmin.bat and examine the result by entering:

DISPLAY QCF(SampleQCF)
DISPLAY Q(SampleQueue)

You have just created a mapping between the JMS and MQ worlds.

Modify the JNDI bindings file

When you want to modify the bindings file, you can modify and rerun the script again. When it starts, it removes the JMS queue connection factory SampleQCF and the JMS queue SampleQueue, then re-creates the queues:

JMeter -- Additional required libraries

This article uses JMeter V2.3.1. In the lib dir of JMeter, install the following additional libraries:

JARObtained via

mail.jar

JMeter site

activation.jar

JMeter site

com.ibm.mq.jar

MQ installation

com.ibm.mqjms.jar

MQ installation

connector.jar

MQ installation

dhbcore.jar

MQ installation

fscontext.jar

MQ installation

jms.jar

MQ installation

jta.jar

MQ installation

providerutil.jar

MQ installation

mqcontext.jar

SupportPac ME01

com.ibm.mq.pcf-6.0.3.jar

SupportPac MS03


JMeter -- JMS point to point

Start JMeter and add a JMS point-to-point sampler. You can download the sample JMeter test plan below. In the point to point sampler, add the following values:

AttributeDescriptionValue

QueueConnection Factory

JNDI name of the queue connection factory to use to connect to the messaging system

SampleQCF

JNDI Name Request queue

JNDI name of the queue to which the messages are sent

SampleQueue

Content

Content of the message.

Whatever you like -- we have added an XML message

Initial Context Factory

Factory to be used to look up the JMS Resources

com.sun.jndi.fscontext.RefFSContextFactory

Provider URL

URL for the JMS provider

file:C:\\IBM\\MQ\\Java\\JNDI


The JMeter sampler should look like this:


Figure 3
Figure 3

JMeter -- Run the test

Select Run => Start. The icon in the list should turn green. If it turns red, then you have configured something wrong, in which case you should review this article and examine the jmeter.log file in the bin directory of JMeter.


Figure 4
Figure 4

JMeter -- verify the result

Browse the queue using rfhutil and verify that the message is there:


Figure 5
Figure 5

Conclusion

This article showed you how to connect JMeter to WebSphere MQ over JMS, including:

  • Setting up MQ series with a queue manager and a queue;
  • Creating a JNDI bindings file that describes the queue manager and the queue and their JMS names.
  • Configuring JMeter to use the JMS names and to retrieve the details from the JNDI file.

When you run JMeter, it inserts a message into WebSphere MQ, which can be a helpful step towards a fully automated test of your system.



Download

DescriptionNameSizeDownload method
Code sampleJMeterPlan.zip3 KBHTTP

Information about download methods


Resources

About the authors

Ronald van de Kuil has been working for IBM since 1998. He has experience with java in contact centre environments. Lately Ronald has delved into J2EE programming. You can contact Ronald at ronald.van.de.kuil@nl.ibm.com.

Dick Sol has been working for IBM since 1998. He has experience with ZLinux, WebSphere Application Developer, Lotus Domino/Notes, Oracle Applications, HR Access and Java. You can contact Dick at dick_sol@nl.ibm.com.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=332331
ArticleTitle=Using JMeter with WebSphere MQ
publish-date=08202008
author1-email=ronald.van.de.kuil@nl.ibm.com
author1-email-cc=
author2-email=dick_sol@nl.ibm.com
author2-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers