cancel
Showing results for 
Search instead for 
Did you mean: 

How to read IBM MQ Topic messages in soapui using groovy

Highlighted
Contributor

How to read IBM MQ Topic messages in soapui using groovy

Hi,

 

I'm planning to write groovy scripts in soapui to read IBM MQ topic messages. Have placed all the dependent jar files in soapui bin/ext folder.Have added below code in groovy script test step

try {
MQTopicConnectionFactory cf = new MQTopicConnectionFactory();
// Config
cf.setHostName("<Destination-IP>");
cf.setPort(1414);
cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
cf.setQueueManager("<Queue-Manager-Name>");
cf.setChannel("SYSTEM.DEF.SVRCONN");
MQTopicConnection connection = (MQTopicConnection) cf.createTopicConnection();
MQTopicSession session = (MQTopicSession) connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
MQTopicSubscriber subscriber = (MQTopicSubscriber) session.createSubscriber(topic);
// Start the connection
connection.start();
JMSMessage receivedMessage = (JMSMessage) subscriber.receive();
log.info("Received message:" + receivedMessage);
subscriber.close();
session.close();
connection.close();
log.info("SUCCESS");
} catch (JMSException jex) {
log.error(jex.getMessage());
} catch (Exception ex) {
log.error(ex.getMessage());
System.out.println("\\nFAILURE\\n");
}
}

 

If there are short messages, the whole message string is displayed whereas if there is along message only part of the message is displayed.

Appreciate if any one can help me in resolving the above issue.

Thanks in advance.

 

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors