1

I've been assigned the task of using Apache Jmeter to connect to an MQ. Unfortunately, I'm not the admin of the MQ, and all my attempts to get more information about it have gotten me nowhere. What I have now is a queue name (call it q), a queue manager (its name, anyway; call it v), a host (w), a port (x), a channel (y), a user (z), and a test message I'm supposed to send across. The object of the game is straightforward: send the test message from Apache Jmeter to the MQ (after which I'll ask the admins whether the message went through or not). In other words, I need help figuring out what to do with Jmeter.

The MQ is version 8.0.0.4. I already have Jmeter installed, so I don't need advice on that (unless there's some special way it should have been installed for this task).

The links provided in this question's answer didn't get me very far. They seemed largely unrelated to what I was trying to do (and also imprecise in their instructions).

JoshMc
  • 10,239
  • 2
  • 19
  • 38

1 Answers1

2
  1. Download 8.0.0.4-WS-MQ-Install-Java-All file
  2. Run it like java -jar 8.0.0.4-WS-MQ-Install-Java-All.jar and accept the license agreement
  3. Add all .jars from wmq/JavaSE/ folder to JMeter Classpath
  4. Restart JMeter to pick the .jars up
  5. Add JSR223 Sampler to your Test Plan and put the following code into "Script" area:

    import com.ibm.msg.client.jms.JmsFactoryFactory
    import com.ibm.msg.client.wmq.WMQConstants
    
    import javax.jms.Session
    
    // 1
    def hostName = "127.0.0.1"
    def hostPort = 1414
    def channelName = "DEV.APP.SVRCONN"
    def queueManagerName = "QM1"
    def queueName = "DEV.QUEUE.1"
    
    // 2
    def ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER)
    def cf = ff.createConnectionFactory()
    
    // 3
    cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, hostName)
    cf.setIntProperty(WMQConstants.WMQ_PORT, hostPort)
    cf.setStringProperty(WMQConstants.WMQ_CHANNEL, channelName)
    cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT)
    cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, queueManagerName)
    
    // 4
    def conn = cf.createConnection("app", "")
    def sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE)
    
    // 5
    def destination = sess.createQueue(queueName)
    
    conn.start()
    

See IBM MQ testing with JMeter - Learn How article for more information if needed.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Two things: First, there's no adding a JSR223 sampler without adding a Thread Group first. How should I configure it? Second, on each run, I get the following error: `2018-04-17 15:35:24,973 ERROR o.a.j.p.j.s.JSR223Sampler: Problem in JSR223 script JSR223 Sampler, message: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: JmsConstants for class: Script2 javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: JmsConstants for class: Script2` Thoughts? – man_of_dalmasca Apr 17 '18 at 20:19
  • First: you should configure thread group according to your performance test plan. By default it will run 1 virtual user 1 time. Second: my example code doesn't have `JmsConstants` anywhere, you should ask the person who added this property there. – Dmitri T Apr 18 '18 at 05:21
  • This seems to be working. Is this code from the standard Groovy documentation? If not, can you link me to something I can use for reference? Also, do you have any pointers for listening for a reply? (Note that I upvoted your comment, though it probably doesn't show.) – man_of_dalmasca Apr 18 '18 at 20:16