RabbitMQ using AMQP Connector

 

In this post, we will explore how to interact with RabbitMQ using MuleSoft’s Anypoint Connector for AMQP (AMQP Connector). This connector allows applications to publish and consume messages using an AMQP 0.9.1-compliant broker, making it an efficient choice for integrating messaging systems.

RabbitMQ is a robust and reliable messaging and streaming broker that is easy to deploy on cloud environments, on-premises, and on local machines. Here are some of its key features:

  • Interoperable: Supports multiple open standard protocols, including AMQP 1.0 and MQTT 5, with various client libraries available.
  • Flexible: Provides many options you can combine to define how your messages go from the publisher to one or many consumers. Routing, filtering, streaming, federation, and so on, you name it.
  • Reliable: With the ability to acknowledge message delivery and to replicate messages across a cluster, you can ensure your messages are safe with RabbitMQ.

Setting Up RabbitMQ 

Let’s use a cloud RabbitMQ service through CloudAMQP.

  • Go to https://www.cloudamqp.com/ and create a free account.
  • Then, create a new Instance using the plan “Little Lemuer”. It doesn’t cost anything and it’s all we need.
  • Copy the username and password by clicking on the name of the plan you created. This will be used to connect to the RabbitMQ service from the MuleSoft application.

 

Creating a Queue: Now click on ‘RabbitMQ Manager’ > ‘Queues and Streams’. From the ‘Add a new queue’ section, provide a valid name and hit ‘Add queue’. (In my case it’s MULESOFT-QUEUE)

 

Create an Exchange: Navigate to ‘Exchanges’. From the ‘Add a new exchange’ section, provide a valid name and hit ‘Add exchange’. (In my example ‘MULESOFT’)

 

Binding Exchange to Queue: Click on the Exchange name you just created. From the ‘Bindings’ section, select ‘To queue’, enter the name of the queue created and hit ‘Bind’. Every message published on Exchange now flows to the queue.

 

Setting Up Mulesoft Application

In Anypoint Studio create a new Mule Project, Create two simple flows to Publish and Consume messages from RabbitMQ Server.

Publish Flow (Sends message to RabbitMQ Exchange.)

 

Subscriber Flow (Consumes message from Queue)

 

AMQP Config ( Use values from Setting Up RabbitMQ section)

 

Debug the project.

Source Code: https://github.com/raghavendrashetty93/mule-rabbitmq-implementation

 


Post Submitted by:

Raghavendra Shetty
Senior Integration Developer | Condenast Technology Labs
LinkedIn Profile
  
Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
 
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.


Share this:
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments