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.
- Creating JMS Server
- Creating JMS Module
- Creating Queue
- 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
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.
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.
Creating Queue:
Step 1: Provide ‘Name’ as DestinationQueue and ‘JNDI Name’ as jms.DestinationQueue.
Step 2: Provide a name for the sub deployment and click ‘OK’. This sub deployment is used for grouping and targeting resources.
Then select the target JMS server
Queue is created successfully.
Creating Topic:
Step 1: Provide name as DestinationTopic and JNDI name as jms.DestinationTopic
Step 2: Provide a name for the sub deployment and click OK. This sub deployment is used for grouping and targeting resources.
Then select the target JMS server.
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”.
Step 3: In the transport tab configure the JMS queue and provide Endpoint URI
Step 4: In the transport tab of JMS click destination type as “Queue”, Message Type as “Text”, Response Queues as “None”
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”.
Step 3: In the transport tab configure the JMS Topic and provide Endpoint URI
Step 4: In the transport tab of JMS click destination type as “Topic”, Message Type as “Text”, Response Queues as “None”
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”.
Step 3: In the transport tab configure the JMS queue and provide Endpoint URI
Step 4: In the transport tab of JMS click destination type as “Queue”, Message Type as “Text”, Response Queues as “None”
JMS Producer and Consumer Testing:
Executing consists of two scenarios.
- Enable the service
- Disable the service
Scenario: 1 Enable the Service:
Execute “JMSProducer” proxy service from OSB console
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.
Destination Topic consumes the message as follows.
Summary of the JMS message consumed
Scenario 2: Disable the Service:
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.
By following the above steps we have configured and executed the producer and consumer using JMS Queues and topics.