Forum Discussion
larryx
11 years agoFrequent Contributor
Hello
I use Matthias' groovy sample code to clear JMS Message from queue (SoapUI Pro-HermesJMS). However, I got "groovy.lang.MissingPropertyException" error (attached) which complain the line "queues.each{". Could anyone have idea? Please Help Me!! Thanks.
Note: I used groovy to send messages to the Queue already. Below is my code:
import com.eviware.soapui.impl.wsdl.submit.transports.jms.JMSConnectionHolder
import com.eviware.soapui.impl.wsdl.submit.transports.jms.JMSEndpoint
import com.eviware.soapui.impl.wsdl.submit.transports.jms.util.HermesUtils
import hermes.Hermes
import javax.jms.*
// This is the name of the session from your hermes-config.xml. Search for 'session'. It also shows in the URL and in my case it's the Queue Manager name.
def hermesSssionName = "activeMQSession";
//List queues = ["MyQueueName1, MyQueueName2"];
List queues = ["testQ1, testQ1"];
queues.each{
def queueName = "${it}"
def jmsEndPoint = new JMSEndpoint("jms://" + hermesSssionName + "::queue_" + queueName + "::queue_" + queueName);
def hermes = HermesUtils.getHermes(testSuite.getProject(), jmsEndPoint.getSessionName())
def jmsConnectionHolder = new JMSConnectionHolder(jmsEndPoint,hermes,false,null,null,null);
log.info("hermesSssionName:" + hermesSssionName);
log.info("queueName:" + queueName);
Session session = jmsConnectionHolder.getSession();
Queue queue = jmsConnectionHolder.getQueue(jmsConnectionHolder.getJmsEndpoint().getReceive());
MessageConsumer consumer = session.createConsumer(queue);
Message message = null;
while((message = consumer.receiveNoWait()) != null){
log.info(message);
//do nothing
}
jmsConnectionHolder.closeAll()
}
I use Matthias' groovy sample code to clear JMS Message from queue (SoapUI Pro-HermesJMS). However, I got "groovy.lang.MissingPropertyException" error (attached) which complain the line "queues.each{". Could anyone have idea? Please Help Me!! Thanks.
Note: I used groovy to send messages to the Queue already. Below is my code:
import com.eviware.soapui.impl.wsdl.submit.transports.jms.JMSConnectionHolder
import com.eviware.soapui.impl.wsdl.submit.transports.jms.JMSEndpoint
import com.eviware.soapui.impl.wsdl.submit.transports.jms.util.HermesUtils
import hermes.Hermes
import javax.jms.*
// This is the name of the session from your hermes-config.xml. Search for 'session'. It also shows in the URL and in my case it's the Queue Manager name.
def hermesSssionName = "activeMQSession";
//List queues = ["MyQueueName1, MyQueueName2"];
List queues = ["testQ1, testQ1"];
queues.each{
def queueName = "${it}"
def jmsEndPoint = new JMSEndpoint("jms://" + hermesSssionName + "::queue_" + queueName + "::queue_" + queueName);
def hermes = HermesUtils.getHermes(testSuite.getProject(), jmsEndPoint.getSessionName())
def jmsConnectionHolder = new JMSConnectionHolder(jmsEndPoint,hermes,false,null,null,null);
log.info("hermesSssionName:" + hermesSssionName);
log.info("queueName:" + queueName);
Session session = jmsConnectionHolder.getSession();
Queue queue = jmsConnectionHolder.getQueue(jmsConnectionHolder.getJmsEndpoint().getReceive());
MessageConsumer consumer = session.createConsumer(queue);
Message message = null;
while((message = consumer.receiveNoWait()) != null){
log.info(message);
//do nothing
}
jmsConnectionHolder.closeAll()
}
Related Content
- 2 years ago
Recent Discussions
- 6 days ago
- 10 days ago