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!

17 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
  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. This is Fixed, after I got my IBM MQ installed and reset all settings.
    However it is not able to do:
    a. Ramp up users/threads
    b. Sending same messages using a 2nd thread

    error:
    Sample Start: 1969-12-31 18:00:00 CST
    Load time: 0
    Connect Time: 0
    Latency: 0
    Size in bytes: 0
    Headers size in bytes: 0
    Body size in bytes: 0
    Sample Count: 1
    Error Count: 1
    Data type ("text"|"bin"|""):
    Response code: 000
    Response message: com.ibm.msg.client.jms.DetailedInvalidClientIDException: JMSCC0111: WebSphere MQ classes for JMS attempted to set a pre-existing client ID on a Connection or JMSContext. An application attempted to set the client ID property of a valid Connection or JMSContext to the value 'ABCD-Client' but this value was already in use.
    The clientId had already been set by Thread[Thread - A 1-1,6,main]
    Wed Oct 12 10:43:52 CDT 2016
    : java.lang.Thread.getStackTrace(Unknown Source)
    : com.ibm.msg.client.jms.internal.JmsConnectionImpl$ClientIDSetter.(JmsConnectionImpl.java:120)
    : com.ibm.msg.client.jms.internal.JmsConnectionImpl.checkDuplicateClientID(JmsConnectionImpl.java:344)
    : com.ibm.msg.client.jms.internal.JmsConnectionImpl.(JmsConnectionImpl.java:283)
    : com.ibm.msg.client.jms.internal.JmsQueueConnectionImpl.(JmsQueueConnectionImpl.java:67)
    : com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl._createConnection(JmsConnectionFactoryImpl.java:276)
    : com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createConnection(JmsConnectionFactoryImpl.java:236)
    : com.ibm.mq.jms.MQConnectionFactory.createCommonConnection(MQConnectionFactory.java:6024)
    : com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:136)
    : com.ibm.mq.jms.MQQueueConnectionFactory.createConnection(MQQueueConnectionFactory.java:209)
    : org.apache.jmeter.protocol.jms.Utils.getConnection(Utils.java:203)
    : org.apache.jmeter.protocol.jms.client.Publisher.(Publisher.java:130)
    : org.apache.jmeter.protocol.jms.sampler.PublisherSampler.initClient(PublisherSampler.java:142)
    : org.apache.jmeter.protocol.jms.sampler.PublisherSampler.sample(PublisherSampler.java:163)
    : org.apache.jmeter.protocol.jms.sampler.BaseJMSSampler.sample(BaseJMSSampler.java:87)
    : org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:465)
    : org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:410)
    : org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:241)
    : java.lang.Thread.run(Unknown Source)
    . Ensure that the connection is valid and that the client ID is unique.

    Thanks
    Ram

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

    ReplyDelete
  7. Hi
    We have ActiveMQ broker and JMS messaging, We developed application (Desktop application in JavaFX) which uses ActiveMQ to send and receive data, Server side also ActiveMQ installed which receive data and update in database with different flags and later response will be delivered to client.
    Here ActiveMQ installed in client side and server side to communicate JMS mechanism.
    My scenario:
    Desktop application can be installed in different machines which treated as number of clients, How can we do load test in this scenario.

    ReplyDelete
  8. This is a vey very useful article.Thank you.

    ReplyDelete
  9. Great and I have a dandy provide: Who Repairs House Windows Near Me exterior makeover

    ReplyDelete
  10. Respect and I have a super present: How To Properly Renovate A House contractor for home renovation

    ReplyDelete