Forum Discussion

Said's avatar
8 years ago

Automate loading message in HermesJMS from SOAPUI



Currently I am manually loading messages on a queue in HermesJMS, via Send TextMessage (Ctrl +S).

The name of the session is: WMQ_PRIVATE_SESSIONNAME

The name of the queue is: O.APP_TO.ESB.TST.DATA


I would like to automate this manual step in SoapUI via a groovy script. I am using SoapUI 5.0.0. I found sample code at Smarbear. Below is the code partly adjusted.


import com.eviware.soapui.impl.wsdl.submit.transports.jms.JMSConnectionHolder
import com.eviware.soapui.impl.wsdl.submit.transports.jms.util.HermesUtils
import com.eviware.soapui.impl.wsdl.submit.transports.jms.JMSEndpoint
import hermes.Hermes
import javax.jms.* "jms endpoint zetten" testRunner.testCase.testSuite.project.hermesConfig

//def jmsEndpoint = new JMSEndpoint("jms://activeMQSession::queue_testQ1::queue_testQ1");

// testRunner.testCase.testSuite.project.getPropertyValue ("Hermes Config") "hermes zetten"
//def hermes = HermesUtils.getHermes( context.testCase.testSuite.project, jmsEndpoint.sessionName)
//def hermes = HermesUtils.getHermes( "H:/.hermes/hermes-config.xml", jmsEndpoint.sessionName)
def hermes = HermesUtils.getHermes( testRunner.testCase.testSuite.project.hermesConfig , jmsEndpoint.sessionName ) "jms connectionholder"
def jmsConnectionHolder = new JMSConnectionHolder( jmsEndpoint, hermes, false, null ,null ,null);

Session queueSession = jmsConnectionHolder.getSession();

Queue queueSend = jmsConnectionHolder.getQueue( jmsConnectionHolder.getJmsEndpoint().getSend() );

Queue queueBrowse = jmsConnectionHolder.getQueue( jmsConnectionHolder.getJmsEndpoint().getReceive() );

MessageProducer messageProducer = queueSession.createProducer( queueSend );

TextMessage textMessageSend = queueSession.createTextMessage();

textMessageSend.setText( "jms message from groovy");

messageProducer.send( textMessageSend );

textMessageSend.setText( "another jms message from groovy");

messageProducer.send( textMessageSend );

QueueBrowser qb = queueSession.createBrowser(queueBrowse);

Enumeration en= qb.getEnumeration();

TextMessage tm = (TextMessage)en.nextElement(); tm.getText()

jmsConnectionHolder.closeAll()// don't forget to close session and connection



The line below gives error: javax.naming.NamingException: : error at line 18

def hermes = HermesUtils.getHermes( testRunner.testCase.testSuite.project.hermesConfig , jmsEndpoint.sessionName


I have a project propery "Hermes Config"

The value is: "H:/.hermes"


Can someone tell me why this error occurs and how to do to fix this issue?

Also is this the right way to go (to automate loading TextMessage)?


Thanks in advance,



3 Replies

    • nmrao's avatar
      Champion Level 3
      def hermes = HermesUtils.getHermes(context.testCase.testSuite.project, jmsEndPoint.sessionName)
      def jmsConnectionHolder = new com.eviware.soapui.impl.wsdl.submit.transports.jms.JMSConnectionHolder(jmsEndPoint, hermes, false, clientID, username, password)

       See if this is helpful.

      • Said's avatar

        Thanks for you suggestion Rao.

        I pasted this:

        def hermes = HermesUtils.getHermes(context.testCase.testSuite.project, jmsEndPoint.sessionName)


        But I get this error on that line:

        groovy.lang.MissingPropertyException: No such property: jmsEndPoint for class: Script2 error at line: 22.


        I added line below to check the sessionName "jmsEndpoint.sessionName: " + jmsEndpoint.sessionName


        Gives: jmsEndpoint.sessionName: WMQ_PRIVATE_SESSIONNAME


        I get the session name there. Could it be an issue with processing hermes-config.xml?