Sending JSON Data to an AMQP Queue

(0 reviews)

home

Shows you how to use the AMQP connector to send JSON data to RabbitMQ, an open source message broker that implements AMQP.

Example

In this example a message containing sample sales data in JSON is received through an HTTP endpoint. This message is then converted to a string using a transformer and then sent to RabbitMQ using the AMQP connector. Once this message reaches the queue, it can be viewed throught he RabbitMQ web console.

Set Up and Run the Example

  1. After making sure that RabbitMQ is running, log in to the RabbitMQ web admin console at http://localhost:15672
  2. Go to the Exchanges tab and click on Add a new Exchange to create an exchange called sales_exchange. You may leave the other feilds as they are and then click on Add exchange.
  3. Now go to the Queues tab and click on Add a new queue to create a queue called sales_queue. You may leave the other fields as they are and then click on Add queue.
  4. Click on sales__exchange under the Exchanges tab and then go to the section titled Add binding from this exchange. In the To queue field type in sales_queue and then click on Bind.
  5. Open and run the example project in the studio interface.
  6. Make a HTTP POST request using Postman, curl or the REST Console to send the following JSON data: {"ITEM_ID"= 001, "ITEM_NAME" = "Shirt", "QTY" = 1, "PRICE" = 20}
  7. Now, navigate back to the RabbitMQ web admin console. You should notice an increase in the number of messages in sales_queue. You may also view the message by clicking on sales_queue in the Get messages option.

Documentation

Read full documentation in GitHub


Reviews

TypeExample
OrganizationMulesoft
Published by
MuleSoft Organization
Published onJun 14, 2019
Asset overview

Asset versions for 2.1.x

Asset versions
VersionActions
2.1.4