Anypoint Exchange

Home to the complete listing of connectors, templates, examples and APIs.
Discover and use proven assets built by the MuleSoft ecosystem, or add assets to a private
tenant of Anypoint Exchange for collaboration and sharing of internal best practices.

Learn more
Sign up
Sending JSON to a JMS Queue

Sending JSON to a JMS Queue

(0 reviews)

Illustrates how to use ActiveMQ, an open source JMS implementation from Apache that supports JMS 1.1 specification.

Anypoint Studio offers easy-to-use components to connect to JMS Queues and Topics.

screenshot from Anypoint Studio


In this example, an HTTP request holding the JSON sales data reaches the HTTP endpoint in the byte array format. A transformer then converts the JSON data from a byte array into a string. A success message is logged and the string is added to a JMS queue. Once a message reaches the JMS queue it can be viewed through the activeMQ admin console.

Set Up and Run the Example

Complete the following procedure to create, then run this example in your own instance of Anypoint Studio.

  1. Download this example application to Anypoint Studio. Do not run the application yet.

  2. Start the ActiveMQ server, navigate to the ActiveMQ home directory in the command terminal, and use the bin/activemq start command to start the activeMQ server. You should see a message that is similar to this indicating that your activeMQ server is running:

    INFO: Using java '/System/Library/Frameworks/JavaVM.framework/Home/bin/java'
    INFO: Starting - inspect logfiles specified in and to get details
    INFO: pidfile created : . . . 
  3. Configure the project build path by adding the ActiveMQ JAR file to the project folder. Right click the project folder in the Package Explorer, and click Properties > Java Build Path. Under the Libraries tab, click Add External Jars.

  4. Browse to the ActiveMQ home directory and add the JAR file named activemq-all-5.4.3.jar - the ActiveMQ version at the time of this documentation was 5.4.4. Click Open > Ok.

  5. In the Package Explorer, right-click the project, and click Run As > Mule Application. Studio runs the application on the embedded server and connects to the localhost on the port to which the HTTP endpoint is configured.

  6. Send JSON Data to the URL using the REST console. You can use curl to do so. Use the following screenshot as a guide to fill in the required details within the REST console. Click Send to send the JSON data as an HTTP request to your localhost server.

     Request URI: http://localhost:8081/sales
     Request method: POST
     Body : {"ITEM_ID"= 001, "ITEM_NAME" = "Shirt", "QTY" = 1, "PRICE" = 20}
  7. Log in to ActiveMQ admin page at http://localhost:8161/admin/queues.jspwith the default username and password β€œadmin”. View if the message was added to the queueIn the ActiveMQ queue, click on the sales link and then on the link under the message ID column. On doing so, you can see details of the message that was added to the JMS queue:


Read full documentation in GitHub

Examples to Try Next

If you understood this example
JMS Message Rollback and Redelivery - Learn how to implement JMS rollback and redelivery using activeMQ MOM.View
If you struggled with this example
Sending JSON Data to an AMQP Queue - Learn how to use the AMQP connector to send JSON data to RabitMQ.View


Log into Anypoint Platform to download this asset


Created by
MuleSoft Organization
Published onJun 22, 2017


VersionRuntime version