how to groovy script with jms websphere
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how to groovy script with jms websphere
Hi there,
do any of you guys have a groovy script that works with jms and Websphere MQ?
I'm struggling with the concept..
Regards
SP
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Stephanus,
The script works fine on my side with the list of jars from your screenshot. BTW, can you connect using the direct connection: https://support.smartbear.com/readyapi/docs/testing/jms/config.html?
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can connect through HermesJMS config.
If I open JMS (Configure JMS) I press green arrow on the configs, I get no message so I think its working.
This how ever does not fix my problem with the error message I'm getting.
Do you have a groovy script that I can use with HermesJMS?
If I want to as JMS Destination to project I 'm getting an error. Check the Error attached.
I also added the Hermes JMS screen to show that it works with the config file.
Regards
SP
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Natasya
Please check my amended, response on previous...
Regards
SP
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Stephanus,
Please see my comments:
>> If I open JMS (Configure JMS) I press green arrow on the configs, I get no message so I think its working.
You should have the message that the Connection successfully tested.
>> Do you have a groovy script that I can use with HermesJMS?
The script from the Working With JMS From Groovy Scripts article works for the WebSphere provider too, you just need to change the jmsEndpoint value.
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.* //Establishing the JMS connection def jmsEndpoint = new JMSEndpoint("jms://activeMQSession::queue_testQ1::queue_testQ1"); def hermes = HermesUtils.getHermes( context.testCase.testSuite.project, jmsEndpoint.sessionName) def jmsConnectionHolder = new JMSConnectionHolder( jmsEndpoint, hermes, false, null, null, null); // Obtaining the session and queue Session queueSession = jmsConnectionHolder.getSession(); Queue queueSend = jmsConnectionHolder.getQueue( jmsConnectionHolder.getJmsEndpoint().getSend() ); Queue queueBrowse = jmsConnectionHolder.getQueue( jmsConnectionHolder.getJmsEndpoint().getReceive() ); // Performing some actions MessageProducer messageProducer = queueSession.createProducer( queueSend ); TextMessage textMessageSend = queueSession.createTextMessage(); textMessageSend.setText( "A JMS message sent from ReadyAPI."); messageProducer.send( textMessageSend ); textMessageSend.setText( "Another JMS message sent from ReadyAPI."); messageProducer.send( textMessageSend ); // Logging elements QueueBrowser qb = queueSession.createBrowser(queueBrowse); Enumeration en = qb.getEnumeration(); while(en.hasMoreElements()) { TextMessage tm = (TextMessage)en.nextElement(); log.info tm.getText() } jmsConnectionHolder.closeAll() // Make sure to close the session and connection
>> If I want to as JMS Destination to project I 'm getting an error. Check the Error attached.
This error occurs when the session isn't properly configured in HermesJMS.
>> I also added the Hermes JMS screen to show that it works with the config file.
Can you see the queues content in HermesJMS for the configured session: https://www.screencast.com/t/xuQK0QtFlDC
You can also open a new support case here: https://support.smartbear.com/message/?prod=ReadyAPI
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for getting back to the conversation, @stephanusts.
If the questions were answered, can you please click the Accept as Solution button below the appropriate reply? This will help our members find the answer easier.
Thanks,
Olga Terentieva
SmartBear Assistant Community Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Nastya_Khovrina@stephanusts@Olga_T
I have used the second code to connect to IBM MQ. But i am getting error as mentioned below when i run this through soapui.
My code:
import com.ibm.msg.client.wmq.*;
import com.ibm.mq.jms.*;
import javax.jms.*;
//public void testMQConnectionMode() throws JMSException {
// MQConnectionFactory qcf = new MQConnectionFactory();
// assertThat(cf.getIntProperty(CommonConstants.WMQ_CONNECTION_MODE), is(equalTo(CommonConstants.WMQ_CM_BINDINGS)));
// cf.setIntProperty(CommonConstants.WMQ_CONNECTION_MODE, CommonConstants.WMQ_CM_CLIENT);
// assertThat(cf.getIntProperty(CommonConstants.WMQ_CONNECTION_MODE), is(equalTo(CommonConstants.WMQ_CM_CLIENT)));
//}
MQQueueConnectionFactory qcf = new MQQueueConnectionFactory();
// Host and port settings have their usual meanings
qcf.setHostName ("hostname");
qcf.setPort (portno);
// Queue manager and channel — the W-MQ administrator should
// supply these
qcf.setQueueManager ("Queuemanager");
qcf.setChannel ("channelname");
// Although there are many possible values of transport type,
// only 'client' and 'bindings' work in a Java client. Bindings
// is a kind of in-memory transport and only works when the client
// and the queue manager are on the same physical host. In most
// cases we need 'client'.
qcf.setTransportType (WMQConstants.WMQ_CM_BINDINGS);
QueueConnection qc = qcf.createQueueConnection ();
// QueueConnection qc = qcf.createQueueConnection ("Username","password\$"); //set credentials
qc.start();
// Create a queue and a session
Queue q = new MQQueue ("MQ");
Queue q1 = new MQQueue ("MQ1");
QueueSession s = qc.createQueueSession (false, Session.AUTO_ACKNOWLEDGE);
// Create and send a TextMessage
QueueSender qs = s.createSender (q);
Message m = s.createTextMessage ("Hello, World!");
qs.send (m);
// Receive a TextMessage
QueueReceiver qr = s.createReceiver(q1);
qr.receive();
Error:
Tue Oct 16 16:36:13 IST 2018:ERROR:com.ibm.msg.client.jms.DetailedJMSException: JMSFMQ6312: An exception occurred in the Java(tm) MQI. The Java(tm) MQI has thrown an exception describing the problem. See the linked exception for further information.
com.ibm.msg.client.jms.DetailedJMSException: JMSFMQ6312: An exception occurred in the Java(tm) MQI. The Java(tm) MQI has thrown an exception describing the problem. See the linked exception for further information.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.ibm.msg.client.commonservices.j2se.NLSServices.createException(NLSServices.java:313)
at com.ibm.msg.client.commonservices.nls.NLSServices.createException(NLSServices.java:388)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7ProviderConnection(WMQConnectionFactory.java:7178)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:6583)
at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createConnection(JmsConnectionFactoryImpl.java:295)
at com.ibm.mq.jms.MQConnectionFactory.createCommonConnection(MQConnectionFactory.java:6232)
at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:115)
at javax.jms.QueueConnectionFactory$createQueueConnection.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at Script1.run(Script1.groovy:29)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:90)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:250)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: com.ibm.mq.jmqi.local.LocalMQ$3: CC=2;RC=2495;AMQ8598:
-----------------------------------------------------------------------
| Failed to load the WebSphere MQ native JNI library: 'mqjbnd'.
|
| The JVM attempted to load the platform native library 'mqjbnd',
| which was mapped to the filename: 'mqjbnd.dll'.
|
| When attempting to load the library, the JVM reported the error
| message:
| 'no mqjbnd in java.library.path'
|
| The JVM's bit-size is: '64'
|
| The library path which was used to locate this library was:
| '*** Configured java.library.path **********************************
| "C:\Program Files\SmartBear\SoapUI-5.3.0/bin"
| ********************************************************************'
|
| Check that the bit size of the JVM matches the bit size of the first
| native library file located within this java.library.path directory
| list.
|
| The native library 'mqjbnd' is used by the WebSphere MQ classes for
| Java and WebSphere MQ classes for JMS when creating a connection to
| the queue manager using a 'bindings' mode connection. A bindings
| mode connection is a connection which uses the system's memory to
| communicate with the queue manager, as opposed to a 'client' mode
| connection which uses a TCP/IP socket.
|
| In order to communicate with a queue manager using a bindings mode
| connection, the queue manager must be located on the same system as
| the WebSphere MQ classes for Java/JMS. If this is not the case in
| your environment, consider reconfiguring the application to utilise
| client mode connections.
-----------------------------------------------------------------------
at com.ibm.mq.jmqi.local.LocalMQ.loadLib(LocalMQ.java:1125)
at com.ibm.mq.jmqi.local.LocalMQ.access$300(LocalMQ.java:166)
at com.ibm.mq.jmqi.local.LocalMQ$1.run(LocalMQ.java:299)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.mq.jmqi.local.LocalMQ.initialise_inner(LocalMQ.java:285)
at com.ibm.mq.jmqi.local.LocalMQ.initialise(LocalMQ.java:250)
at com.ibm.mq.jmqi.local.LocalMQ.<init>(LocalMQ.java:1187)
at com.ibm.mq.jmqi.local.LocalServer.<init>(LocalServer.java:188)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.ibm.mq.jmqi.JmqiEnvironment.getInstance(JmqiEnvironment.java:707)
at com.ibm.mq.jmqi.JmqiEnvironment.getMQI(JmqiEnvironment.java:639)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7ProviderConnection(WMQConnectionFactory.java:7170)
... 15 more
Caused by: java.lang.UnsatisfiedLinkError: no mqjbnd in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.ibm.mq.jmqi.local.LocalMQ.loadLib(LocalMQ.java:1087)
... 29 more
Any answer why this error is coming?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@stephanusts@Nastya_Khovrina@Olga_T
How to get current queue depth from the IBM MQ using groovy?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sanjana,
It seems that you can use the getCurrentDepth() method. Please see the following articles:
- http://tech.forums.softwareag.com/techjforum/posts/list/46218.page
- https://stackoverflow.com/questions/8656245/check-mq-queue-depth
- http://www.mqseries.net/phpBB2/viewtopic.php?p=367344#367344
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

- « Previous
-
- 1
- 2
- Next »
- « Previous
-
- 1
- 2
- Next »