Author: Shivam Shakya
In this blog, we will learn about the integration of MuleSoft with Amazon MQ and how to create an Amazon MQ.
What is Amazon MQ?
Amazon MQ is a managed message broker service provided by Amazon Web Services (AWS). It enables you to decouple the components of your applications using a messaging protocol. Amazon MQ is based on the Apache ActiveMQ message broker, which is a popular open-source messaging platform. It supports multiple messaging protocols such as MQTT, AMQP, OpenWire, and STOMP, enabling you to connect various types of clients and applications. With Amazon MQ, you can easily set up and operate message brokers without the need to manage the underlying infrastructure. It takes care of tasks such as hardware provisioning, software installation, maintenance, and scaling, allowing you to focus on developing your applications.
Prerequisite:
- Anypoint Platform Account
- Anypoint Studio 7.6 or later
- AWS account credentials
Amazon MQ configuration
Follow the below steps to create Amazon MQ:
- Search AWS MQ in the AWS search console.
- Click on Get Started.

- We have 2 broker engines present for Amazon MQ. A broker engine is a type of message broker that runs on Amazon MQ. Please select Apache ActiveMQ.

- Choose the deployment mode and storage type for amazon MQ. Single-instance Broker is for Single Availability Zone and Active/standby broker is for high availability and automatic failover.

- Configuration setting for Amazon MQ.




- Broker Creation will take about 20 minutes. Broker’s configuration can be found on the configuration page.



- Once a Broker is created, open that broker and click on the Active MQ web Console URL.

- Click on the Manage Active MQ Broker.

NOTE: If the ActiveMQ GUI is not working, open Amazon MQ in AWS. Then, click on “Security Groups” within the Amazon MQ interface. Inside the security group, click on “Edit Inbound Rules” and add the system’s public IP for ports 8162 and 61617.
Port 8162 is used to access the GUI.
Port 61617 is used for MuleSoft Configuration.



- We will get a pop-up for Username and password. Use the same credentials which we used while creating the broker in AWS.

- Create a Queue or Topic.


We have completed the Lambda configuration in AWS. Let’s check how to call this Amazon MQ in MuleSoft code.
MuleSoft Code Configuration
- Create a Mule application with JMS publish and On-New-Message connectors. We will post data in Queue using JMS publish and then consume that data from On-New-Message.
- For JMS configuration, we need username and password which we used while creating the broker in AWS and Broker URL which we can get from Amazon MQ Endpoints.OpenWire URL is used for BrokerURL.


- Click Test Connection.

MuleSoft Flows


Testing Mule API
- Use the Postman to test our API.

- MuleSoft Publish Flow.

- Message published into the Queue Successfully.

- MuleSoft Consume Flow.

- Message consumed successfully from the queue.

I hope you find this article helpful. Thanks for reading.
References:
https://aws.amazon.com/amazon-mq/
https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/configuration.html