Reading Time: 5 minutes

Mule Studio offers easy-to-use components to connect to JMS Queues and Topics. In today's example, we're going to learn how to use ActiveMQ, a leading open source JMS implementation from Apache that supports JMS 1.1 specification.

Here's an outline of the simple steps required to implement this example:

  • Import ActiveMQ libraries
  • Create an ActiveMQ connector
  • Enqueue to JMS Queue
  • Run the sample
latest report
Learn why we are the Leaders in management and

1. Import ActiveMQ Library

Download ActiveMQ binaries from http://activemq.apache.org/download.html. In this example, I am using the ActiveMQ 5.4.3 release. Unzip the compressed file to any folder on your file system. Let's call it <ACTIVEMQ_HOME>.

Create a new flow in Mule Studio

[singlepic id=42]

We can see that the ActiveMQ library is now available under Build path.
[singlepic id=49 w=580 h=355]

2. Create an ActiveMQ Connector

Double-click on “jms” flow to bring up the message flow. Click on the “Global Elements” tab. Click on “Create” and locate ActiveMQ under “Connectors -> JMS”. Leave the default values for the Active_MQ connector and click OK.

[singlepic id=44 w=580 h=355]

will initialize the ActiveMQ connector with a default instance of the ActiveMQ connection factory and establish a TCP connection to the remote standalone broker running on a local host and listening on port 61616.

3. Enqueue to JMS Queue

We will use the request payload received from an HTTP inbound endpoint to seed the ActiveMQ Queue. Open the “jms” message flow and drag and drop an HTTP endpoint on to the flow.

Double-click on the HTTP endpoint to bring up the properties dialog. Specify “jms” for Path. This will make the HTTP endpoint accessible using URL  http://localhost:8081/jms.

[singlepic id=46 w=580 h=355]

Drag and drop a JMS endpoint next to the HTTP inbound endpoint.

Double-click the JMS endpoint to bring up the properties dialog. Specify “StudioIN” for Queue name. This dialog also allows specifying properties for transactions and exchange patterns. We will explore these concepts in future lessons.

[singlepic id=47 w=580 h=355]

Click on the References tab and select “Active_MQ” for Connection Reference. We created the “Active_MQ” connector in Step 2.

[singlepic id=48 w=580 h=355]

Click OK to save these properties and return to JMS Message Flow.

[singlepic id=52]

We are now ready to run this sample.

4. Run the sample

First, run ActiveMQ using executable “activemq” from <ACTIVEMQ_HOME>/bin folder. Make sure you can access the ActiveMQ admin page using http://localhost:8161/.

[singlepic id=43 w=580 h=355]

In Mule Studio, right-click on “jms” and select “Run as Mule Flow”.

Open http://localhost:8081/jms. This will enqueue the request to the ActiveMQ JMS Queue “StudioIN”.

Verify this by examining the ActiveMQ administration page at http://localhost:8161/admin/queues.jsp. We can see that there is 1 message under the “Messages Enqueued” column.

[singlepic id=50 w=580 h=355]

More details on ActiveMQ can be found in the Mule 3 User Guide.