Friday, July 25, 2014

JMeter and WebSphere MQ Series integration

    JMeter is a popular tool for executing load tests. There is much information about it on the web. However, integration of JMeter with WebSphere MQ Series (JMS provider) is not that common. Let's try to do it!
The goal is to send a particular number of messages per second using JMeter and WebSphere MQ as a message broker. The first thing to do is to generate .binding file. That file contains information about message broker and queue to which we want to connect. You can use WebSphere MQ Explorer and follow this link for instructions regarding .binding file creation. Make sure that you specified the right address to message broker (for some reason there was 'localhost' set in my .binding file) within ConectionFactory and the channel name is also correct. Once you obtain .binding file you should prepare JMeter. First of all WebSphere MQ client jars:
com.ibm.mq-7.5.0.2.jar
com.ibm.mqjms-7.5.0.2.jar
com.ibm.dhbcore-7.5.0.2.jar
com.ibm.mq.headers-7.5.0.2.jar
com.ibm.mq.jmqi-7.5.0.2.jar
must be copied to:
JMeter/lib
folder. Then you need to create a test plan:
Make sure that you specified the right localization of the folder containing .binding file and ConnectionFactory and Destination names are exactly the same as you specified during .binding file creation.
JMeter is ready to go. You can start torturing your application. Have fun!

9 comments :

  1. This is almost helpful. If you could explain about the .binding file and examples of the ConnectionFactory and Destination names... and maybe text version of the InitialContextFactory. thanks.

    ReplyDelete
    Replies
    1. I think I'm in a similar boat - I connect using Camel which have never needed a bindings file

      Delete
    2. I think I'm in a similar boat - I connect using Camel which have never needed a bindings file

      Delete
  2. For those trying to get this working I also stumbled upon this blog that helped me with the initial idea, and here is what I had to do to finally make it work.

    Have an MQ Client installed (not necessarily on the JMeter server) - I did this using MQ Client 7.5.0.5 for Windows.


    1 - Needed to add additional libs from MQ + the ones listed to Jmeter/lib (such as fscontext for context factory)
    My final list was.

    com.ibm.mq.headers.jar
    com.ibm.mq.jmqi.jar
    com.ibm.mqjms.jar
    dhbcore.jar
    fscontext.jar
    jms.jar
    jndi.jar
    providerutil.jar

    2 - Create the dir JNDI-Directory on the C: drive. You will need this to save .bindings file.

    3 - To create the bindings file go to an MQ client install (:IBM\WebSphere MQ\java\bin) and run JMSAdmin.bat

    In the command prompt - define the parameters as below, replacing your values.

    InitCtx> def qcf(connection_factory_name) transport(CLIENT) channel(mq_channel) host(mq_server_hostanem) port(mq_server_port) qmgr(mq_qmgr_name)
    InitCtx> def q(destination_q_name) qmgr(mq_qmgr_name) queue(destination_q_name)
    InitCtx> end

    This will create the .bindings file that you will move to the JMeter Server and reference in the JMS Publisher sampler.

    Initial context is the same as in the screenshot. All other parameters are self explanatory.

    In my version of JMeter the JMS Publisher sampler has an expiration and priority fields, which if I left blank throw a Java error. I set them to 9999 and 4 respectively.


    Hope this helps.




    ReplyDelete
  3. I have JMeter sending message to MQ Server to which i have full access. But my JMeter is throwing the following error:

    Response message: javax.naming.NamingException: javax.naming.InvalidNameException: tcpip://xxxxxx.com:YYYY [Root exception is java.net.MalformedURLException: unknown protocol: tcpip]

    What could be the issue?

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  4. I could not install MQ Client 7.5.0.5 for Windows - as it is throwing another errror:

    -> Could not create the Java Virtual Machine.

    ??

    Thanks
    Ram

    ReplyDelete
  5. It is nice articles, sure helps for load performance testing on application side. But message queue has own storage, it stores all messages even it process or not.

    Websphere MQ Admin Training online and class room

    Websphere MQ Admin Training in Chennai

    ReplyDelete
  6. This is a very very useful article. Thank you so much.

    ReplyDelete