Using WebSphere ESB with WebSphere MQ to support publish/subscribe messaging

This article shows you how to use the JMS capabilities in WebSphere ESB to implement publish/subscribe messaging by leveraging the underlying WebSphere MQ environment.

Share:

Rahul Pisal (rahul.pisal@in.ibm.com), Integration Architect, IBM India, IBM

Photo of NAMERahul Pisal is an Integration Architect with IBM India. He is an engineering graduate with 15 years of IT experience, 12 of them in the integration domain. Before joining IBM, he worked with the webMethods product suite, and at IBM he works on successfully implementing BPM, SOA, and integration solutions using IBM products such as IBM Business Process Manager, WebSphere ESB, WebSphere Message Broker, and WebSphere MQ. You can contact Rahul at rahul.pisal@in.ibm.com.



20 March 2013

Introduction

This article uses the following IBM® products:

  • IBM Integration Designer V8 (for development)
  • IBM WebSphere® Enterprise Service Bus V8
  • IBM WebSphere MQ V7.5

The Service Component Architecture (SCA) framework provides three different types of bindings to choose from for SCA import:

  • MQ Binding
  • MQ JMS Binding
  • JMS Binding

WebSphere ESB, by virtue of its underlying WebSphere Application Server components, supports publish/subscribe messaging implemented using the default messaging provider. While this article does not use that scenario, it explains the steps needed when you already have WebSphere MQ as the underlying messaging provider. WebSphere MQ V7 or later provides out-of-the-box support for publish/subscribe messaging.

This article shows you how to use the WebSphere MQ JMS binding to implement publish/subscribe messaging for seamless integration of events and data. The steps in this article will work on WebSphere MQ V7 or later and WebSphere ESB V6.2 or later.

The example below uses a simple customer order business object . The diagram shows the overall scenario. A real-world scenario might have MQ Export and MQ-JMS Import in separate modules, and a more complex object structure. The goal here is to show how MQ-JMS binding helps implement publish/subscribe messaging.

You can download the complete working solution at the bottom of the article. You will still need to complete the prerequisite steps below if you download and test the module. The CustomerOrder business object (BO) used in this article looks like this:

Prerequisite steps

Complete the following steps before starting the development:

  1. Make sure that WebSphere MQ is running. If the default configuration was created when WebSphere MQ was installed, you might already have a queue manager created. If not, create a new queue manager.
  2. Create three local queues as shown below:
  3. Create a Topic named TMS.CUSTOMERORDER with Topic String TMS/CUSTOMERORDER/#:
  4. Create the following two subscriptions to the topic, where the endpoints are the two queues defined in Step 2:
  5. Make sure the WebSphere ESB server is running and log in to the Administrative Console using the admin user ID.
  6. Select Resources => JMS => Topic connection factories:
  7. Click New and provide the details as shown below:
    • Make sure that Transport selected is Client. Bindings type does not work with a local queue manager (coexisting on the same server as WebSphere ESB).
    • Make sure that the WebSphere MQ messaging provider is selected:
  8. Click OK and save the configuration
  9. Select Resources => JMS => Topics:
  10. Click New and provide the information as shown below:
  11. Make sure that the Topic String defined while setting up the Topic in WebSphere MQ is used to specify the Topic Name in the above step.

Developing the solution

  1. Create a new Mediation Module project named MQPubSubModule. In actual project scenarios, you will create a new library and create the BOs and interfaces inside the library for better modularization. Since this is a demo, the necessary artifacts are created directly in the mediation module.
  2. Define a new BO named CustomerOrder:
  3. Define a new interface named CustomerOrderService with only one operation -- a one-way operation to demonstrate the publish/subscribe scenario:
  4. Select the defined BO as input while defining the interface.
  5. Open the assembly diagram.
  6. Drag and drop MQ binding from the Inbound Exports drawer onto the canvas.
  7. Specify the following properties while configuring the MQ Export. The screenshots below show the details after the MQ Export is completely configured. You provide the values shown below while configuring the MQ Export wizard:
    1. Select the Interface defined earlier:
    2. Specify the Bindings as shown below:
    3. Specify the Endpoint Configuration as shown below. Values for your environment may be different. Make sure that the Transport is Client and that Enable connection at startup is checked:
    4. For Method Binding, select UTF8XMLHandler:
    5. Keep Security Attributes as blank:
    6. The final Summary page should look like this:
    7. This sample uses the Specify properties option while configuring MQ Export
  8. MQ Import supports only the point-to-point model, and therefore this example uses MQ JMS Import to demonstrate the publish/subscribe messaging model.
  9. Drag and drop MQ JMS binding from Outbound Imports drawer on to the canvas.
  10. Specify the following properties while configuring the MQ JMS import. The screenshots below show the details after the MQ JMS import is completely configured. You provide the values shown below while configuring the MQ JMS Import wizard.
  11. In actual projects, the interface on MQ Export and MQ JMS Import may be different, and you may need to use a mediation flow in between to map source to target. To keep things simple, this example assumes that the export and import use the same interface.
    1. Select the interface defined earlier:
    2. Specify the Bindings details as shown below:
    3. Specify the Endpoint Configuration details as shown below. Use the already configured JNDI details:
    4. Specify the Method Bindings as shown below:
    5. Keep the Security Attributes empty and leave the message configuration as-is. The Summary screen should like this:
  12. Wire the export to the import, which adds the following entry on the MQ Export:
  13. Deploy the mediation module to the WebSphere ESB server

Testing the solution with WebSphere MQ Explorer

  1. Open WebSphere MQ Explorer if it is not already open.
  2. Connect to the queue manager on which the queues are defined.
  3. Right-click on the CUSTOMERORDER.NOTIFY queue and select Put test message:
  4. Use the following XML message for testing:
    <?xml version="1.0" encoding="UTF-8"?>
    <n1:CustomerOrder xmlns:n1="http://MQPubSubModule">
    <CustomerNo>C1000</CustomerNo>
    <OrderNo>O1000</OrderNo>
    <PartNo>P1000</PartNo>
    <Quantity>10</Quantity>
    <OrderAmount>3.14167</OrderAmount>
    </n1:CustomerOrder>
  5. Make sure that the line breaks are removed before placing the message on the queue:
  6. Click Put message.
  7. Close the window and click Browse on either of the two destination queues.
  8. The Message Data window shows the following details:
  9. Double-click on any message and click on Data on the window that opens:
  10. Copy and paste the data from the Message data field into a text editor. The response should look like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <p:sync xmlns:p="http://MQPubSubModule">
      <p:CustomerOrder xmlns:n1="http://MQPubSubModule">
    <CustomerNo>C1000</CustomerNo>
    <OrderNo>O1000</OrderNo>
    <PartNo>P1000</PartNo>
    <Quantity>10</Quantity>
    <OrderAmount>3.14167</OrderAmount>
    </p:CustomerOrder>
    </p:sync>

Conclusion

This article showed you how to use MQ Export and MQ-JMS Import bindings to implement publish/subscribe messaging using the underlying WebSphere MQ platform.


Download

DescriptionNameSize
Code sampleMQPubSubModule.zip10 KB

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into WebSphere on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=861895
ArticleTitle=Using WebSphere ESB with WebSphere MQ to support publish/subscribe messaging
publish-date=03202013