Contact Free trial Login

WebSphere MQ Example

Mule Runtime Engine versions 3.5, 3.6, and 3.7 reached End of Life on or before January 25, 2020. For more information, contact your Customer Success Manager to determine how you can migrate to the latest Mule version.

Enterprise Edition, CloudHub

The WebSphere MQ example demonstrates how to use the Websphere MQ Transport to send and receive transactional messages to WebSphere MQ. This example is available in Mule Enterprise Edition.

Cooperate with WMQ

wmq At times, you may find the need to bridge a communication gap between IBM’s message queue product, Websphere MQ, and Mule. To facilitate message processing across products, Mule uses a WMQ Endpoint.


This document assumes that you are familiar with Mule ESB and the Anypoint Studio interface. To increase your familiarity with Studio, consider completing one or more Anypoint Studio Tutorials.

This document describes the details of the example within the context of Anypoint Studio, Mule ESB’s graphical user interface (GUI), and includes configuration details for both the visual and XML editors.

Set Up and Run the Example

As with other example templates, you can create template applications straight out of the box in Anypoint Studio or Mule Standalone (Mule ESB without Studio). You can tweak the configurations of these use case-based templates to create your own customized applications in Mule.


Before you run the example, ensure that your system meets the following conditions:

  • Mule Enterprise is installed

  • WebSphere MQ 6 or 7 is installed

  • the WebSphere MQ client JARs are available to you

Follow one of the two procedures below to create, then run the Websphere MQ application in Anypoint Studio or Mule Standalone.

Studio Visual Editor

  1. Create the example application in Anypoint Studio. Do not run the application.

  2. Add your WebSphere MQ client libraries to the project build path.

  3. Make sure your WebSphere MQ installation has queues named "in" and "out."

  4. Run the application. When the application starts, you may see some exceptions in the output console, since WMQ is not configured (we will configure it in the next step).

  5. Edit the following properties in `(located at `src/main/resources) with the values appropriate for your WebSphere MQ installation:
  6. After configuring WMQ, restart the application.


  1. Copy your WebSphere MQ client JARs to your $MULE_HOME/lib/user directory.

    <MULE_HOME> is the root directory of your Mule installation, for example /opt/Mule/mule-standalone-3.5.0.
  2. Ensure that your WebSphere MQ installation has queues named "in" and "out."

  3. Copy the example’s zip file, for example, <MULE_HOME>/examples/wmq/, to the $MULE_HOME/apps directory.

  4. Start Mule, then wait for it to install the example. You may see some exceptions in the logs, since WMQ is not configured yet (we configure it in the next step).

How to start the Mule server:

There are several ways to start/stop the Mule server:

  • Using the Mule Management Console, which provides a graphical interface for managing servers

  • Using the command line

    Generally, the simplest way to start the server is by using the command line:

  • On a Linux/Unix system, run the following command:

<MULE_HOME>/bin/mule start

On a Windows system, go to the <MULE_HOME>\bin by running the following command:

cd <MULE_HOME>\bin
  1. Edit the following properties in the file <`MULE_HOME>/apps/mule-example-wmq/classes/` with the values appropriate for your Websphere MQ installation:
  2. After configuring WMQ, restart Mule or reload the application.

How to reload the Websphere MQ app without restarting Mule (Unix)

If you modify the Websphere MQ application while Mule is running, you can reload the application without restarting Mule by "touching" (updating the timestamps of) the file <MULE_HOME>/apps/mule-example-bookstore-3.5.0/mule-config.xml.

To update the timestamps, run the following command:

touch <MULE_HOME>/apps/mule-example-wmq-3.5.0/mule-config.xml

Mule automatically reloads the application, activating any modifications.

In this section we will demonstrate basic usage of the application: sending text messages, then retrieving them from a Websphere MQ using Mule.

  1. After Mule starts up, open a Web browser and navigate to the following URL:

  2. The application prompts you to enter text to send a message to WebSphere MQ. The app transmits your input via AJAX/WMQ to the Mule application’s "in" queue and you will receive confirmation that your message has been submitted. Enter some text, then hit "Send".

  3. Mule processes the message sent to the "in" queue, then it sends the confirmation to you via the "out" queue and WMQ/AJAX. Note that Mule introduces an intentional 15 second delay between receiving your message and sending you a confirmation . Mule notifies you when the message is received and its content will be added to the table below.

  4. Play with it! Start typing several messages in the text box, then hit "Send" to submit them to Mule via AJAX/WMQ. After 15 seconds of intentional delay, the Mule confirms receipt of the messages.


How it works

Global Elements

Mule configures the WMQ connector with the values previously defined on the file. In Anypoint Studio, this configuration is stored as a Global Element, named wmqConnector. To view the configured global element, click the Global Elements tab under the canvas, then double-click the wmqConnector Global Element. Studio displays the Global Element Properties, shown below:

Studio Visual Editor


Studio XML Editor or Standalone

<wmq:connector name="wmqConnector" hostName="${}" port="${wmq.port}" queueManager="${wmq.queue.manager}" username="${wmq.username}" password="${wmq.password}" doc:name="WMQ Connector">

To be able to send and receive Mule events asynchronously to and from a web browser, the application uses an AJAX connector. To view the configured global element for the AJAX connector, click the Global Elements tab under the canvas, then double-click the ajaxServer Global Element. Studio displays the Global Element Properties, shown below:

Studio Visual Editor


Studio XML Editor or Standalone

<ajax:connector name="ajaxServer" serverUrl=""
   resourceBase="${app.home}/docroot" disableReplyTo="true" doc:name="Ajax"/>


The application contains three flows, which process, then retrieve messages from a WMQ.

Input flow

The first building block in the flow is an AJAX Inbound Endpoint, which listens for messages on the configured channel, /services/wmqExample/enqueue. The flow adds the incoming messages to the "in" queue.

MessageProcessor Flow

The MessageProcessor flow reads from the "in" queue. The flow’s test component appends a string to the message, waits 15 seconds, then adds the message to the 'out' queue.

Output Flow

The Output flow reads messages from the "out" queue, then publishes via the AJAX outbound endpoint.

Studio Visual Editor


Studio XML Editor or Standalone

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="" xmlns:ajax="" xmlns:core="" xmlns:doc="" xmlns:ee="" xmlns:json="" xmlns:spring="" xmlns:stdio="" xmlns:test="" xmlns:wmq="" xmlns:xsi="" xsi:schemaLocation=" ">
        <spring:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="property-placeholder">
            <spring:property name="location" value=""/>
    <wmq:connector doc:name="WMQ Connector" hostName="${}" name="wmqConnector" password="${wmq.password}" port="${wmq.port}" queueManager="${wmq.queue.manager}" username="${wmq.username}">
    <ajax:connector disableReplyTo="true" doc:name="Ajax" name="ajaxServer" resourceBase="${app.home}/docroot" serverUrl=""/>
    <flow doc:name="Input" name="Input">
        <ajax:inbound-endpoint channel="/services/wmqExample/enqueue" doc:name="Ajax"/>
        <message-properties-transformer doc:name="Message Properties">
            <delete-message-property key="MULE_REPLYTO"/>
        <wmq:outbound-endpoint connector-ref="wmqConnector" doc:name="WMQ" queue="in"/>
    <flow doc:name="MessageProcessor" name="MessageProcessor">
        <wmq:inbound-endpoint connector-ref="wmqConnector" doc:name="WMQ" queue="in">
            <wmq:transaction action="ALWAYS_BEGIN"/>
        <test:component appendString=" - processed" logMessageDetails="true" waitTime="15000"/>
        <wmq:outbound-endpoint connector-ref="wmqConnector" doc:name="WMQ" queue="out">
            <wmq:transaction action="ALWAYS_JOIN"/>
    <flow doc:name="Output" name="Output">
        <wmq:inbound-endpoint connector-ref="wmqConnector" doc:name="WMQ" queue="out"/>
        <ajax:outbound-endpoint cacheMessages="true" channel="/services/wmqExample/dequeue" doc:name="Ajax"/>

See Also

Was this article helpful?

πŸ’™ Thanks for your feedback!

Edit on GitHub