cancel
Showing results for 
Search instead for 
Did you mean: 

EMS receiving reply from temporary topic/queue

SOLVED
Occasional Contributor

EMS receiving reply from temporary topic/queue

Can you please advise how to receive a reply from a temporary topic/queue using JMS Request?

1 ACCEPTED SOLUTION

Accepted Solutions
Occasional Contributor

Re: EMS receiving reply from temporary topic/queue

I managed to achieve this using Groovy script.

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.*

def jmsEndpoint = new  JMSEndpoint("jms://LOCAL::topic_<topicName>::topic_");
def hermes = HermesUtils.getHermes(context.testCase.testSuite.project, jmsEndpoint.sessionName);
def jmsConnectionHolder = new JMSConnectionHolder( jmsEndpoint, hermes, false, null ,null ,null);

Session jmsSession = jmsConnectionHolder.getSession();
Topic temporatyTopic = jmsSession.createTemporaryTopic();

Topic topicPublisher = jmsConnectionHolder.getTopic(jmsConnectionHolder.getJmsEndpoint().getSend());

MessageProducer messageProducer = jmsSession.createProducer(topicPublisher);

TextMessage textMessageSend = jmsSession.createTextMessage();
textMessageSend.setJMSReplyTo(temporatyTopic);
textMessageSend.setText( "jms message from groovy");

messageProducer.send(textMessageSend);

MessageConsumer messageConsumer = jmsSession.createConsumer(temporatyTopic);
String receivedMessage = messageConsumer.receive().getBody(String.class);
log.info(receivedMessage);

jmsConnectionHolder.closeAll();


Can I archive the same functionality using JMS Request step?

7 REPLIES 7
Highlighted
Community Hero

Re: EMS receiving reply from temporary topic/queue

How are you using the endpoing?


Regards,
Rao.
Occasional Contributor

Re: EMS receiving reply from temporary topic/queue

I'm using the following endpoint: readyjms://EMS::topic_<topicName>::topic_ 

 

According to what I found this topic_ should create a temporary topic for a reply. Is it correct?

Community Hero

Re: EMS receiving reply from temporary topic/queue

No topic name mentioned. That means listens on the temporary queue for the reply.


Regards,
Rao.
Occasional Contributor

Re: EMS receiving reply from temporary topic/queue

Yes, but JMS header JMSReplyTo is not set. Therefore component doesn't know where to send the reply.

image.png

 

Can you advise how can set temporary topic in JMSReplyTo and the listen on it for a reply?

Occasional Contributor

Re: EMS receiving reply from temporary topic/queue

I managed to achieve this using Groovy script.

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.*

def jmsEndpoint = new  JMSEndpoint("jms://LOCAL::topic_<topicName>::topic_");
def hermes = HermesUtils.getHermes(context.testCase.testSuite.project, jmsEndpoint.sessionName);
def jmsConnectionHolder = new JMSConnectionHolder( jmsEndpoint, hermes, false, null ,null ,null);

Session jmsSession = jmsConnectionHolder.getSession();
Topic temporatyTopic = jmsSession.createTemporaryTopic();

Topic topicPublisher = jmsConnectionHolder.getTopic(jmsConnectionHolder.getJmsEndpoint().getSend());

MessageProducer messageProducer = jmsSession.createProducer(topicPublisher);

TextMessage textMessageSend = jmsSession.createTextMessage();
textMessageSend.setJMSReplyTo(temporatyTopic);
textMessageSend.setText( "jms message from groovy");

messageProducer.send(textMessageSend);

MessageConsumer messageConsumer = jmsSession.createConsumer(temporatyTopic);
String receivedMessage = messageConsumer.receive().getBody(String.class);
log.info(receivedMessage);

jmsConnectionHolder.closeAll();


Can I archive the same functionality using JMS Request step?

Community Hero

Re: EMS receiving reply from temporary topic/queue

Why no use groovy step then(instead of other type of test step)?


Regards,
Rao.
Occasional Contributor

Re: EMS receiving reply from temporary topic/queue

I'm just curious if it's possible to do the same using JMS Request test set.

New Here?
Join us and watch the welcome video:
Join the Online Event to Win
Top Kudoed Authors