Showing posts with label IBM WebSphere MQ. Show all posts
Showing posts with label IBM WebSphere MQ. Show all posts

Wednesday, 22 February 2017

How to use hermes jms in soapui for IBM MQ

How to use hermes jms in soapui for IBM MQ


I discussed on my previous post about how to configure HermesJMS in SOAP UI for IBM MQ.

Today, I am going to discuss about how we will use JMS Session which we created during configuration of hermes jms for sending/receiving messages to/from Queue from SOAP UI.

Prerequisite
  • Destinations/Queues must be created on IBM MQ and Channels are must be started if any.
  • SOAP UI must be configure with Hermes JMS. 
  • JMS session and Destinations/Queues must be defined.

In previous post, we created JMS Session and destinations as below.

How to use hermes jms in soapui for IBM MQ


Use of Hermes JMS in SOAP UI

HermesJMS is an extensible console that helps Tester to create test cases making it easy to browse or search queues and topics, copy messages around and delete them.

Step 1: Create New SOAP Project using any dummy WSDL. You can use WSDL from SoapUI tutorials.

How to use hermes jms in soapui for IBM MQ

How to use hermes jms in soapui for IBM MQ

Once, you will click OK button new SOAP Project will look like below.

How to use hermes jms in soapui for IBM MQ


Step 2: Create New Test Suite by right click on SOAP UI Project created in Step1.

How to use hermes jms in soapui for IBM MQ

How to use hermes jms in soapui for IBM MQ



How to use hermes jms in soapui for IBM MQ

Step 3: Create New Test Case by right click on Test Suite created in Step2.


How to use hermes jms in soapui for IBM MQ


How to use hermes jms in soapui for IBM MQ

Step 4: Create test steps (Type: Test Request) as necessary based on project requirement.

 For example, I will create create three Test Request steps in SOAP UI test case. One Test Request step for Receive Destination Queue to consume message and one Test Request to send request to destination queue and One Test Request step for send and receive messages.


How to use hermes jms in soapui for IBM MQ

How to use hermes jms in soapui for IBM MQ

How to use hermes jms in soapui for IBM MQ

How to use hermes jms in soapui for IBM MQ

Note: Make sure “Add SOAP Response Assertion” check box to be unchecked, otherwise test suite always fails.

Similarly, create HermesTestStep2  and HermesTestStep3. 


How to use hermes jms in soapui for IBM MQ


Step 5: Create JMS Endpoints for Receive and send destinations.


How to use hermes jms in soapui for IBM MQ

How to use hermes jms in soapui for IBM MQ

Step 6: Map JMS Endpoints for Receive and send destinations.


  • send only jms://LocalMQ::queue_Q1
  • receive only jms://LocalMQ::-::queue_Q2
  • send and receive jms://LocalMQ::queue_Q1::queue_Q2
How to use hermes jms in soapui for IBM MQ


For Dynamic mock response, you can write Groovy script and also can set JMS header attribute like ReplyTo, Expiration time, time-out etc.


Related Topic:





Friday, 10 February 2017

Spring jms code with ibm websphere mq example

  Spring jms code with ibm websphere mq example


In this tutorial I am going to discuss How to send,read and listen Messages to IBM MQ using spring jmstemplate. I am going to cover how to configure the IBM MQ, connection factory, Message Queue,Listener container and JmsTemplate.


I used below technologies to execute below program

1.Maven 4.0.0
2.JDK 1.8
3.Spring (spring-core) 4.0.0.RELEASE
4.Spring (spring-jms) 4.0.0.RELEASE
5.Websphere MQ 7.5.0.1
6. springTestVersion 4.0.0.RELEASE
7. junitVersion 4.6

Prerequisite: System installed with IBM WebSphere MQ.

Click here to download full code of this example.

For example, created 3 files (App-context.xml,main.properties and spring.xml under \src\main\resources\)
created 2 files MessageService.java and RequestSendMessageCreator.java under \src\main\java\com\test\testspringjmsmq
created 1 file MessageServiceTest.java under \src\test\java\com\test\testspringjmsmq\
created 2 files DemoMain.java and TestMessageListener.java under \src\main\java\com\example\listener
1 pom.xml file which is automatic created by spring project.
Spring jms code with ibm websphere mq example

POM.xml: To start off we need to obtain the WebSphere MQ JARs. These JARs are proprietary - hence they will not resolve through a public Maven repository like Maven Central. These JARs need to be obtained from the WebSphere MQ installation directory and manually deployed to our local Maven repository. The config below defines the WebSphere MQ dependencies in our Maven POM file.
Spring jms code with ibm websphere mq example

Spring jms code with ibm websphere mq example

main.properties: This properties file contains information about QueueManager, Queue, host and port(listener port).

fromRtpQueue  is Queue name where listener will read messages.
RES.IDS.QUEUE is Queue name where JmsTemplate send messages.
queue_Idsmanager is Queue manager name.
queue_Idshostname is system ip address or localhost.
queue_Idsport is listener port of Queue manager.

Spring jms code with ibm websphere mq example

spring.xml: Spring's JMSTemplate class is the key to simplifying access to the conventional JMS API. It abstracts the common and repetitive boiler-plate code by handling the creation and closing of connections and sessions, sending and receiving of messages and handling of exceptions. JMSTemplate and a few other beans need to be defined in our Spring config.

Spring jms code with ibm websphere mq example

Spring jms code with ibm websphere mq example

Spring jms code with ibm websphere mq example

App-context.xml: This file import spring.xml and create bean for MessageService class.

Spring jms code with ibm websphere mq example


DemoMain.java: This class have main method and method to load application context file.

Spring jms code with ibm websphere mq example

TestMessageListener.java: This class is used for listen text messages from IBM MQ. Whenever any messages will come on configured Queue(I will tell how to configure queue for listener later on this post), this class will listen messages from that queue and as per requirement process.

Spring jms code with ibm websphere mq example

MessageService.java: This class is used for send messages to IBM MQ. For sending message, I used send(destination,messageCreator) of JmsTemplate where messageCreator is object of RequestSendMessageCreator. In RequestSendMessageCreator class you can create message as per your requirement(will discuss on this later on post) and destination is default destination where we need to send message. We can set destination in JmsTemplate or using annotate in MessageService class.
Spring jms code with ibm websphere mq example

RequestSendMessageCreator.java: This class is used for creating message.

Spring jms code with ibm websphere mq example

MessageServiceTest.java: This class will use for Junit test.

Spring jms code with ibm websphere mq example

How to run :  You can run this example by using DemoMain class or Junit test through MessageServiceTest.


Related Topic

IBM MQ reason code 2087 (AMQ4048)