wmq.host=
wmq.port=
wmq.queue.manager=
wmq.username=
wmq.password=
WebSphere MQ Example
Enterprise Edition
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.
Assumptions
This document assumes that you are familiar with Mule ESB. For an overview of basic operations, such as starting the server and locating Mule files, consult the Quick Start Guide to Mule ESB Server and the Management Console.
Prerequisites
Before you run the example, ensure that your system meets the following conditions:
-
Mule Enterprise 3.1 or later is installed
-
WebSphere MQ 6 or 7 is installed
-
The WebSphere MQ client JARs are available to you
Set Up
As with this WebSphere MQ example, you can create template applications straight out of the box in Mule 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.
Follow the procedure below to create, then run the Websphere MQ application in Mule ESB.
-
Complete the procedure in Examples and Exercises to create WebSphere MQ template in Mule Studio, or the WebSphere MQ example in Mule Standalone (Mule ESB without Studio). Create, but do not run the application.
-
Add your WebSphere MQ client libraries to the project build path.
-
Make sure your WebSphere MQ installation has queues named "in" and "out."
-
Start the application by following Step 8 in Examples and Exercises. 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).
-
Edit the following properties in
wmq.properties `(located at `src/main/resources
) with the values appropriate for your WebSphere MQ installation:After configuring WMQ, restart the application.
With Mule Standalone
-
Copy your WebSphere MQ client JARs to your
$MULE_HOME/lib/user
directory. -
Ensure that your WebSphere MQ installation has queues named "in" and "out."
-
Copy the example’s zip file,
<MULE_HOME>/examples/wmq/mule-example-wmq-3.3.1.zip
to the$MULE_HOME/apps
directory. -
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 will configure it in the next step).
-
Edit the following properties in the file <`MULE_HOME>/apps/mule-example-wmq/classes/wmq.properties` with the values appropriate for your Websphere MQ installation:
wmq.host= wmq.port= wmq.queue.manager= wmq.username= wmq.password=
After configuring WMQ, restart Mule or reload the application.
<MULE_HOME> is the root directory of your Mule installation, for example /opt/Mule/mule-standalone-3.3.1.
|
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:
On a Windows system, go to the <MULE_HOME>\bin by running the following command:
.How to reload the Websphere MQ app without restarting Mule (Unix)
image::check.png[]
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.3.1/mule-config.xml .
To update the timestamps, run the following command:
Mule automatically reloads the application, activating any modifications. |
---|
Running the example
In this section we will demonstrate basic usage of the application: sending text messages, then retrieving them from a Websphere MQ using Mule.
-
After Mule starts up, open a Web browser and navigate to the following URL:
-
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".
-
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.
-
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
Mule configures the WMQ connector
with the values previously defined on the wmq.properties
file. In MuleStudio, 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 will display the Global Element Properties, shown below:
To be able to send and receive Mule events asynchronously to and from a web browser, we use an AJAX connector. Double-click the connector in the canvas to display its properties:
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.