VOOZH about

URL: https://dzone.com/articles/mulesoft-integration-with-rabbitmq

โ‡ฑ MuleSoft Integration With RabbitMQ


Related

  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. MuleSoft Integration With RabbitMQ

MuleSoft Integration With RabbitMQ

MuleSoft integration with RabbitMQ to consume messages from a queue.

By May. 26, 21 ยท Tutorial
Likes
Comment
Save
19.1K Views

Join the DZone community and get the full member experience.

Join For Free

This article will explain in detail, how to integrate with RabbitMQ in MuleSoft and read messages from a queue.

Install and Setup RabbitMQ on Mac

In this section, I will explain how to install RabbitMQ on Mac, create a new queue and publish messages to the queue using the RabbitMQ portal.

Step 1: Install RabbitMQ.

brew install rabbitmq

Step 2: Start RabbitMQ Server.

Start RabbitMQ server in the foreground using the below command:

rabbitmq-server

Or start the server in the background using the below command:

brew services start rabbitmq

Step 3: Access RabbitMQ.

http://localhost:15672/

๐Ÿ‘ Access RabbitMQ

Enter both username and password as guest.

Step 4: Create New Queue.

http://localhost:15672/#/queues

Step 5: Publish Message in Queue.

http://localhost:15672/#/queues/%2F/order

Setup Mule Application 

In this section, I will explain how to create a new Mule application, listen on RabbitMQ queue, read a message from the queue.

Step 1: Create a new Mule 4 application:

Open Anypoint Studio click on File -> New -> Application Name (app-rabbitmq-orders).

Step 2: Install AMQP connector from the exchange:

Step 3: Create flow to read the message from order queue:

XML




xxxxxxxxxx
1
14


1
<?xml version="1.0" encoding="UTF-8"?>
2

 
3
<mule xmlns:amqp="http://www.mulesoft.org/schema/mule/amqp" xmlns="http://www.mulesoft.org/schema/mule/core"
4
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
5
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
6
http://www.mulesoft.org/schema/mule/amqp http://www.mulesoft.org/schema/mule/amqp/current/mule-amqp.xsd">
7
<amqp:config name="AMQP_Config" doc:name="AMQP Config" doc:id="de2abf40-5ad2-4942-a874-99d12c486b4b" >
8
<amqp:connection host="localhost" username="guest" password="guest" />
9
</amqp:config>
10
<flow name="app-rabbitmq-ordersFlow1" doc:id="aa37df28-a708-4d2d-8ee1-ee8ca0c4dfd0" >
11
<amqp:listener doc:name="OrderQueueListener" doc:id="88ebbb66-8592-44f2-aee0-2d39ddb66d63" config-ref="AMQP_Config" queueName="order" ackMode="IMMEDIATE"/>
12
<logger level="INFO" doc:name="RqbbitMQ Message" doc:id="4b2c8676-8baf-4ba2-adee-e28f0f1edc06" message="#[payload]"/>
13
</flow>
14
</mule>


Step 4: Test the MuleSoft Application Listener


MuleSoft Integration application Command (computing) Connector (mathematics) Testing XML Flow (web browser)

Opinions expressed by DZone contributors are their own.

Related

  • MDC Logging With MuleSoft Runtime 4.4
  • MuleSoft APIkit Router - QueryParam and Header Strict Validation Configuration
  • How to Use Mulesoft VM Connector
  • Integrate Cucumber in Playwright With Java

Partner Resources

ร—

Comments

The likes didn't load as expected. Please refresh the page and try again.

Let's be friends: