RabbitMQ Integration with Mule 4

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


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


Go to: 
Exchange > amq.topic

amq.topic we need to configured in our mule flow in topic name.

Mule flow:

Publish component configuration:

put exchange name as: amq.topic

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

Add a logger showing payload

Now we have to configure queue in rabbitmq to listen 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 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: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" />
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="702c48f8-15b3-4ca9-a204-d25470bde766" >
<http:listener-connection host="" port="8085" />
<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 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]"/>

No comments:

Post a Comment

If you have any doubt, please let me know

© 2020 goformule.com

Share on :

Mule 4:

XML to JSON in mule 4 Web service consumer VM Validation in Mule 4 Until Successful
Sub flow Set Variable & Remove Variable Set Transaction ID Scatter Gather Round Robin
Consume Restful Service CRUD in Mule 4 Parse Template Object to JSON Load Static Resource
JSON to XML Invoke Idempotent Filter ForEach Flat file to JSON
Fixwidth to JSON First Successful File Execute Error Handling
Email Dynamic Evaluate Custom Business Event CSV to JSON Copybook to JSON
Choice Router Async RabbitMQ

Mule 3:

Database Connector Async CXF Attachement XSLT
Mongo DB Cache scope Custom Business Event Gzip Compress Expression
SMTP For Each Expression Javascript Filter Reference
Salesforce Message Enricher Groovy Parse Template Idempotent
VM Poll Invoke Ruby Message
Webservice consumer Python Transformer reference Message Property Not
Collection Aggregator First Sucessful Catch Exception Strategy Reference Exception Strategy Or
Choice Message Chunk Aggregator Choice Exception Strategy Global Exception Strategy Schema Validation
Custom Aggregator Scatter Gather Custom Exception Strategy Batch Processing MEL
M Unit RAML Map Operator API Mocking Dataweave

Converter Tools :

JSON to XML Converter XML to JSON Converter Decimal to Binary Decimal to Octal Binary to Decimal
Binary to Hexadecimal Binary to Octal Hexadecimal to Decimal Hexadecimal to Binary Hexadecimal to Octal
Octal to Decimal Octal to Binary Octal to Hexadecimal Number to Words Converter Text to Hex Converter
Hex to Text String to Binary Converter Binary to String Converter Word to HTML Converter Word to PDF Converter
JSON to YAML Converter CSV to JSON Converter XML to XSLT Converter XML to YAML Converter
JSON to CSV Converter JSON to TSV Converter CSV to TSV Converter CSV to XLS Converter

Image Tools :

PNG to JPG Converter PNG to BMP Converter PNG to GIF Converter JPG to PNG Converter JPG to BMP Converter
JPG to GIF Converter GIF to PNG Converter GIF to JPG Converter GIF to BMP Converter PNG to PDF Converter
JPEG to PDF Converter JPG to PDF Converter BMP to PDF Converter GIF to PDF Converter

String Utilities :

Reverse String Random String Generator Base64 Encoder Base64 Decoder Words Counter
Remove Accents Remove Duplicate Lines Remove Empty Lines Remove Line Breaks Remove Similar Lines
Sort Text Lines Reverse Text Lines Random Words Generator

Number Utilities :

Square Root Calculator Random Number Generator Area of Circle Calculator Date Calculator

Other Tools :

Find IP of Website Password Generator URL Encoder URL Decoder lorem ipsum Generator
IP to Hostname Port Checker JSON Escape JSON Unescape

Free Rest APIs for Testing :

GET Sample Rest APIs POST Sample Rest API PUT Sample Rest API PATCH Sample Rest API DELETE Sample Rest API
Login Sample Rest API User Registration Sample API User Registration Unsuccessful Sample Rest API Delay Response