Overview
RabbitMQ is a widely-used message broker that enables efficient communication between distributed systems through its reliable message queuing and exchange capabilities. By integrating RabbitMQ with webMethods.io, you can seamlessly subscribe to events, process them in real-time, and drive automation across your business workflows.
In this article, we will explore how to set up a subscription to RabbitMQ events within webMethods.io. The focus will be on leveraging RabbitMQ’s exchange and queue bindings to consume messages and process event-driven data efficiently. Whether you are building an integration to synchronize data between systems, trigger workflows, or monitor system activity, this guide will help you implement a robust and scalable solution.
Through this step-by-step walkthrough, you will gain insights into:
- RabbitMQ environment setup.
- Setting up a connection in webMethods.io to subscribe to RabbitMQ queues.
- Processing and transforming the subscribed data within webMethods.io workflows.
Prerequisite
- Basic understanding of pub/sub model.
- webMethods.io environment.
Install RabbitMQ(Optional)
We will be installing RabbitMQ in a docker container, if you wish to install it in windows/Linux/mac, please check out the official documentation here.
- Run below command to pull RabbitMQ management image from docker hub.
- docker pull rabbitmq:management
- Run below command to deploy the image as a container and map port to host machine.
- docker run -d –name rabbitmq-container \
–restart always \
-p 15672:15672 \
-p 5672:5672 \
-v rabbitmq_data:/var/lib/rabbitmq \
rabbitmq:management
- docker run -d –name rabbitmq-container \
- Navigate to {http/https}://{host}:15672 , it will open RabbitMQ management UI.
- Login using username and password as guest.
- Navigate to Admin>Users tab and create a user with administrator privileges.
Setting up the RabbitMQ environment.
Before setting up the environment below are the key things that we need to know.
Virtual Host (vHost)
A virtual host is a logical grouping within RabbitMQ that acts as a namespace for isolating resources like queues, exchanges, bindings, and permissions.
- It allows you to manage multiple applications on a single RabbitMQ server without conflicts.
- Each vHost has its own set of users and permissions, providing a way to segregate different environments (e.g., development, testing, production).
- Default vHost:
/
(created automatically during RabbitMQ installation).
Queue
A queue is a data structure that stores messages until they are consumed by a client.
- It is where messages are sent by producers and retrieved by consumers.
- Queues operate on a First In, First Out (FIFO) principle unless specific priorities are assigned.
- Key properties of a queue:
- Durable: Survives a broker restart.
- Exclusive: Used by one connection only.
- Auto-delete: Deleted when the last consumer disconnects.
Exchange
An exchange is a routing mechanism in RabbitMQ that decides how messages sent by producers are directed to queues.
- Producers send messages to an exchange rather than directly to a queue.
- The exchange uses routing rules to forward the message to one or more queues or to discard it if no rules match.
- Types of exchanges:
- Direct: Routes messages to a queue based on an exact routing key match.
- Topic: Routes messages to queues based on pattern-matching with the routing key.
- Fanout: Broadcasts messages to all queues bound to it, ignoring the routing key.
- Headers: Routes messages based on custom headers instead of the routing key.
Routing Key
A routing key is a string used to define how messages are routed from an exchange to a queue.
- Its behavior depends on the type of exchange:
- Direct exchange: The routing key must match exactly.
- Topic exchange: Supports pattern matching using
*
(single word) and#
(zero or more words).
- Producers define the routing key when publishing messages, and queues use binding rules to match them.
- Its behavior depends on the type of exchange:
Create Virtual host :
- Login to RabbitMQ management UI.
- Click on Virtual Hosts tab under Admin tab.
- Fill below details and click Add virtual host button.
- Name: Give a name to your virtual hosts.
- Description: give a description to the virtual host.
- Tags : provide a tag to it.
- Default Queue Type: let’s have it default value.
Create an Exchange :
Navigate to Exchange tab and create an Exchange following below snapshot.
Create Queue :
Navigate to Queues and Streams tab and create the Queue by following below snapshot.
Bind queue to exchange :
- Navigate to Exchanges tab and open demo-exchange by clicking on it.
- Bind the queue to exchange by following below snapshot.
- Now we have below details which we will use in webMethods.io to configure the connection.
- Virtual host : dev-vs.
- Exchange : demo-exchange.
- Queue : demo-queue.
- Routing Key : demo-routing
RabbitMQ configuration in webMethods.io :
- Login to webMethods.io integration
- In the Projects tab click on the plus icon to create a new project.
- Open the newly created project and create a workflow using the plus icon.
- Once Workflow is created, it will have start and end point.
- Click in the start icon and it will showing you the gear icon, click on it.
- Once you click on it will allow you to configure the workflow trigger point.
- Search for AMQP , select it and click on Next button.
- Select configure new account and follow below instruction.
- Trigger Label : give it a name.
- AMQP Listener : select subscribe.
- Connect to AMQP : click on plus icon.
- Once Add account pop up is opened fill below details.
- Host : Provide host name of the RabbitMQ server.
- Port : 5672.
- Username : Provide username of the RabbitMQ user.
- Password : Provide password of the RabbitMQ user.
- Virtual Host : Fill dev-vs, if you have created a different one then fill the same here.
- Locale : Fill en_IN.
- Other parameter you can fill based on your requirement and click add button.
- Now in the Queue section fill the queue name that we created previously in RabbitMQ.
- Exchange Type: select direct.
- Exchange Name : provide the exchange name that we created earlier.
- Routing Key : fill the routing key.
- Other parameter you can keep it as it is or adjust it based on your requirement.
- Save it.
- Return to workflow and search for logger.
- Drag and drop the logger in to canvas and connect start to logger and logger to end.
- In the Logger component, map Trigger Data 0 Subscribe to Log Data and save the workflow.
Test Subscription:
- Navigate to RabbitMQ management UI.
- Navigate to Exchanges tab and open the demo-exchange.
- Scroll down to Publish message section.
- In the routing Key fill demo-routing and in the payload fill some message like ‘Hi from RabbitMQ’.
- Once everything is filled click Publish message button.
- One webMethods.io integration and navigate to Monitor tab.
- Select Workflow executions and click on the latest transaction.
- Open the Logger log and you will able to see the message that we have published from RabbitMQ.
Hope you have enjoyed this article!