Forum Discussion

qazwsx's avatar
qazwsx
Occasional Contributor
6 years ago

EMS receiving reply from temporary topic/queue

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

  • 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?

    • qazwsx's avatar
      qazwsx
      Occasional Contributor

      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?

      • nmrao's avatar
        nmrao
        Champion Level 3
        No topic name mentioned. That means listens on the temporary queue for the reply.