0
votes

I have been trying to connect to IBM MQ from JMeter JMS publisher. Unable to find corrert "Initial context factory" and "connection factory" values to use without JNDI properties. I have all MQ jars present in LIB folder.

I have the following information-host name - Venus, Port - 21717, Destination Queue name - request.queue,Queue manager - venus.QMGR,channel - venus.server.chl (no authorization required).

My requirement - To connect to IBM MQ using JMS publisher with above details. But I am not able to sort out on what to give for Provider URL, Initial context factory and connection factory. Can you please help as this has been bugging me for past two weeks and couldn't find a solution yet? It would be great if you can tell me on where to populate the above values in JMS publisher as well for connecting to IBM MQ.

I have tried with user.classpath=/folder/with/mq/jars as well but it is not working and all jars are in place with JMeter restart still no luck.

Note: I have gone through all sites in these two weeks but couldn't get any luck.

2
Possible duplicate of Jmeter to connect to IBM MQuser7294900
Yeah, I have seen that but it is not helpful. I have done all those things but still unable to connect to MQ using JMS publisher/point-to-point.Ajay N

2 Answers

1
votes

Example configuration steps would be something like:

  1. Add javax.jms-api.-x.x.x jar to JMeter Classpath
  2. Add mq-allclient-x.x.x.x.jar to JMeter Classpath
  3. Add JSR223 Sampler to your Test Plan
  4. Put the following code into "Script" area:

    import com.ibm.jms.JMSTextMessage;
    import com.ibm.mq.jms.*;
    import com.ibm.msg.client.wmq.WMQConstants;
    
    import javax.jms.JMSException;
    import javax.jms.Session;
    
    MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
    cf.setHostName("your_IBMMQ_host");
    cf.setPort(1414); // or other port
    cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
    cf.setQueueManager("your_IBMMQ_queue_manager");
    cf.setChannel("your_IBMMQ_channel");
    cf.setStringProperty(WMQConstants.USERID, "your_IBMMQ_username");
    cf.setStringProperty(WMQConstants.PASSWORD, "your_IBMMQ_password");
    connection = (MQQueueConnection) cf.createQueueConnection();
    MQQueueSession session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    MQQueue queue = (MQQueue) session.createQueue("queue:///your_IBMMQ_queue");
    MQQueueSender sender = (MQQueueSender) session.createSender(queue);
    JMSTextMessage message = (JMSTextMessage) session.createTextMessage("your_message_body");
    connection.start();
    sender.send(message);
    

More information:

0
votes

Depending on your exact requirements, you may be interested by JMSToolBox and its possibility to define scriptsthat will read the payload from csv files stored in a directiory, then create and post them in a MQ Q as a JMS Message from a message template