RabbitMQ Integration with Mule 4
RabbitMQ is lightweight and easy to deploy on-premises and in the cloud. It supports multiple messaging protocols. RabbitMQ can be deployed in distributed and federated configurations to meet high-scale, high-availability requirements.
first, we need to download Erlang before installing RabbitMQ.
link: https://www.erlang.org/downloads
Navigation:

Click on download:

Now download RabbitMQ

Click on rabbitmq.com
then rabbitmq-server-3.8.3.exe

Once we install rabbitmq search rabbit command prompt

Open RabbitMQ Command Prompt & execute command to enable GUI:
rabbitmq-plugins enable rabbitmq_management
Once it execute succussfully open rabitmq by: localhost:15672
Put default credentials
login: guest
password: guest
Now
Go to:
Exchange > amq.topic
amq.topic we need to configure in our mule flow in the topic name.

Mule flow:

Publish component configuration:
put exchange name as: amq.topic

Put host, username, and password.
now click on test connection. once a connection is successful, save it.

Add a logger showing payload
Now we have to configure the queue in rabbitmq to listen to the message in our mule listener flow.
Move to tab: Queues
Click on add queue, give some name I have given name demo as shown below.

Once queue is configured we have to bind our topic amq.topic with our queue demo to successfully consume the message in listener flow.
Now, go to tab Exchanges
Click on bind->select queue name

Once topic is bound with queue
we can proceed with Listener Mule flow:

Give queue name: demo
Listener component configuration:

Add logger after this, click save.
URL: http://localhost:8085/rabbit
Input & Output:

Logger Output:

XML project code:
link: https://www.erlang.org/downloads
Navigation:
Click on download:
Now download RabbitMQ
Click on rabbitmq.com
then rabbitmq-server-3.8.3.exe
Once we install rabbitmq search rabbit command prompt

Open RabbitMQ Command Prompt & execute command to enable GUI:
rabbitmq-plugins enable rabbitmq_management
Once it execute succussfully open rabitmq by: localhost:15672
Put default credentials
login: guest
password: guest
Now
Go to:
Exchange > amq.topic
amq.topic we need to configure in our mule flow in the topic name.
Mule flow:
Publish component configuration:
put exchange name as: amq.topic
Put host, username, and password.
now click on test connection. once a connection is successful, save it.
Add a logger showing payload
Now we have to configure the queue in rabbitmq to listen to the message in our mule listener flow.
Move to tab: Queues
Click on add queue, give some name I have given name demo as shown below.
Once queue is configured we have to bind our topic amq.topic with our queue demo to successfully consume the message in listener flow.
Now, go to tab Exchanges
Click on bind->select queue name
Once topic is bound with queue
we can proceed with Listener Mule flow:
Give queue name: demo
Listener component configuration:
Add logger after this, click save.
URL: http://localhost:8085/rabbit
Input & Output:
Logger Output:
XML project code:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:amqp="http://www.mulesoft.org/schema/mule/amqp" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 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
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/amqp http://www.mulesoft.org/schema/mule/amqp/current/mule-amqp.xsd">
<amqp:config name="AMQP_Config" doc:name="AMQP Config" doc:id="4bee0105-f34a-4742-a1da-1c6c8ac2ee78" >
<amqp:connection host="localhost" username="guest" password="guest" />
</amqp:config>
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="702c48f8-15b3-4ca9-a204-d25470bde766" >
<http:listener-connection host="0.0.0.0" port="8085" />
</http:listener-config>
<flow name="test_rabbitmqFlow" doc:id="dbf284f6-8a5e-411d-b6b8-2a14797ba34e" >
<http:listener doc:name="Listener" doc:id="176e24e9-126b-4ed2-861b-d1076ffa29b5" config-ref="HTTP_Listener_config" path="/rabbit"/>
<amqp:publish doc:name="Publish" doc:id="9545b62f-916b-4b8f-9ba6-2994a29c08ea" exchangeName="amq.topic" config-ref="AMQP_Config"/>
<logger level="INFO" doc:name="Logger" doc:id="a78e62c1-fa0b-4e1f-9c61-9f2d44325afe" message="In Publish Logger: #[payload]"/>
</flow>
<flow name="test_rabbitmqFlow1" doc:id="d7809308-1113-44f2-850a-f38613aef433" >
<amqp:listener doc:name="Listener" doc:id="68c83ee9-70ca-4762-b63b-d4d6b5cc4902" config-ref="AMQP_Config" queueName="demo"/>
<logger level="INFO" doc:name="Logger" doc:id="e6c57089-676a-48e9-aeff-fe549529a8f4" message="In Listener Logger : #[payload]"/>
</flow>
</mule>
No comments:
Post a Comment