Skip to main content

Development

How to Implement JMSProducer and JMSConsumer

In this blog post, I have captured the process to implement a JMSProducer and consumer example.

The primary objective is to build an OSB project, which will perform the following functions:

Creating JMS Server, Queues and Topics:

To create a business and proxy service, we have to start with creating a JMS Server, queues and topics.

  1. Creating JMS Server
  2. Creating JMS Module
  3. Creating Queue
  4. Creating Topic

Creating JMS Server:

Step 1: Go to the WebLogic server->Under Domain structure Section, Click on services>Messaging>JMS servers. On JMS servers Page, click on “New” button.

On the create a New JMS server page, provide a name for the server

Picture1

Step 2: After creating the JMS Server, we need to select the Target server instance where we have to deploy our JMS server

Select the Target server from the dropdown list and click ‘Finish’ to complete the JMS server.

Picture2

Creating JMS Module:

Step 1: In the ‘Create JMS System Module’ screen, provide the ‘Name’ and then select the ‘Target -> Servers’ and check the ‘Would you like to add resources to this JMS System module?’ option.

Picture3

Picture4

picture5

Picture6

Creating Queue:

Step 1: Provide ‘Name’ as DestinationQueue and ‘JNDI Name’ as jms.DestinationQueue.

Picture7

Step 2: Provide a name for the sub deployment and click ‘OK’. This sub deployment is used for grouping and targeting resources.

Picture8

Then select the target JMS server

picture9

Picture10

Queue is created successfully.

Creating Topic:

Step 1: Provide name as DestinationTopic and JNDI name as jms.DestinationTopic

Picture11

Step 2: Provide a name for the sub deployment and click OK. This sub deployment is used for grouping and targeting resources.

Picture12

Picture13

Then select the target JMS server.

picture14

After creating queue and topic we can start creating our business and proxy service.

Configure JMSProducer OSB business service:

Step 1: Use “Messaging service as service type” in general Configuration Tab.

Step 2: In messaging tab use “XML” as “Request Message Type”.

picture15

Step 3:  In the transport tab configure the JMS queue and provide Endpoint URI

pic16

Step 4: In the transport tab of JMS click destination type as “Queue”, Message Type as “Text”, Response Queues as “None”

pic17

Configure “JMSProducerToTopic” Business Service:

Step 1: Use “Messaging service as service type” in general Configuration Tab.

Step 2: In messaging tab use “XML” as “Request Message Type”.

pic18

Step 3: In the transport tab configure the JMS Topic and provide Endpoint URI

pic19

Step 4: In the transport tab of JMS click destination type as “Topic”, Message Type as “Text”, Response Queues as “None”

pic20

Configure “JMSConsumer” Proxy service:

Step 1: In the general configuration tab use “Messaging service as service type”.

Step 2: In messaging tab use “XML” as “Request Message Type”.

pic21

Step 3: In the transport tab configure the JMS queue and provide Endpoint URI

pic22

Step 4: In the transport tab of JMS click destination type as “Queue”, Message Type as “Text”, Response Queues as “None”

pic23

JMS Producer and Consumer Testing:

Executing consists of two scenarios.

  1. Enable the service
  2. Disable the service

Scenario: 1 Enable the Service:

Execute “JMSProducer” proxy service from OSB console

pic24

Check in the Destination Queue how many messages have been received from the producer for instance

We have passed Session id value as “23456788”. So total message is 6.

pic25

Destination Topic consumes the message as follows.

pic26

Summary of the JMS message consumed

pic27

Scenario 2: Disable the Service:

pic28

When we disable the proxy service the message gets consumed in the queue and  it will not reach the topic unless we enable the proxy service.

pic29

By following the above steps we have configured and executed the producer and consumer using JMS Queues and topics.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Saviya Krishnamoorthy

More from this Author

Categories
Follow Us