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


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">
  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">


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.

Downloadable resources

Related topics


Sign in or register to add and subscribe to comments.

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