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

- Set up WebSphere MQ with a queue manager and queue.
- 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.
- Configure JMeter to use the JMS names and retrieve the connection details from the JNDI bindings file.
- 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

MQ -- Additional required libraries
Put the following JAR files into the java\lib directory of your MQ installation:
| JAR | Obtained 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 |
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.
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:
| JAR | Obtained 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 |
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:
| Attribute | Description | Value |
|---|---|---|
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

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

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

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.
| Description | Name | Size | Download method |
|---|---|---|---|
| Code sample | JMeterPlan.zip | 3 KB | HTTP |
Information about download methods
- Apache JMeter
Apache JMeter is a Java desktop application from Apache Software Foundation that load tests functional behavior and measures performance of Web and other applications. - Developing a standalone Java application for WebSphere MQ
This article shows how to develop a J2SE Java application that sends and receives messages using WebSphere MQ. The application uses standard JMS and JNDI APIs from J2EE, but does not need to be deployed on a J2EE application server. - Automation for the people: Hands-off load testing
Load testing is often relegated to late in the development cycle, but it doesn't need to be that way. This article shows you how to discover and fix problems throughout the cycle, by creating a scheduled integration build that runs JMeter tests. - WebSphere MQ developer resources page
Technical resources to help you design, develop, and deploy messaging middleware with WebSphere MQ to integrate applications, Web services, and transactions on almost any platform. - WebSphere MQ product page
Product descriptions, product news, training information, support information, and more. - WebSphere MQ V7 trial download
A no-charge trial download of WebSphere MQ V6. Includes limited online support for Windows® and Linux® installations at no charge during the trial period. - WebSphere MQ V6 information center
A single Web portal to all WebSphere MQ V6 documentation, with conceptual, task, and reference information on installing, configuring, and using your WebSphere MQ environment. - WebSphere MQ documentation library
WebSphere MQ product manuals. - WebSphere MQ support page
A searchable database of support problems and their solutions, plus downloads, fixes, problem tracking, and more. - WebSphere MQ public newsgroup
A non-IBM forum where you can get answers to your WebSphere MQ technical questions and share your WebSphere MQ knowledge with other users. - WebSphere MQ SupportPacs
Downloadable code, documentation, and performance reports for the WebSphere MQ family of products. - SupportPac IH03: WebSphere Message Broker V6 Message display, test, and performance utilities (rfhutil)
These utilities are useful for developing and testing WebSphere MQ and WebSphere Message Broker applications. - SupportPac ME01: WebSphere MQ Initial Context Factory
This SupportPac includes Java code that enables a Java program to perform naming and directory service functions through a standard JNDI interface. - SupportPac MS03: WebSphere MQ Save Queue Manager object definitions using PCFs (saveqmgr)
This SupportPac (saveqmgr) interrogates the attributes of all the objects (such as queues and channels) defined in either a local or remote queue manager and saves them to a file. - WebSphere SOA solutions developer resources page
Get technical resources for WebSphere SOA solutions. - developerWorks SOA and Web services zone
Technical resources for evaluating, planning, designing, and implementing solutions that involve SOA and Web services. - developerWorks WebSphere Business Integration zone
For developers, access to WebSphere Business Integration how-to articles, downloads, tutorials, education, product info, and more. - WebSphere Business Integration products page
For both business and technical users, a handy overview of all WebSphere Business Integration products - WebSphere forums
Product-specific forums where you can get answers to your technical questions and share your expertise with other WebSphere users. - Most popular WebSphere trial downloads
No-charge trial downloads for key WebSphere products.
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.




