Amazon SQS Connector in Mule 4

Author: Jiten Chawla

Amazon SQS Connector provides an easy way to interface with Amazon Simple Queue Service API enabling Mule users to manage SQS queuing service without having to interact with API directly

Amazon SQS offers a reliable, highly scalable hosted queue for storing messages as they travel between computers. By using Amazon SQS, developers can move data between distributed application components and perform different tasks without losing messages or requiring each component to be always available

Amazon SQS connector is built using the SDK for JAVA. AWS SDK  for Java provides Java API for AWS services.

Prerequisites

Before using Amazon SQS connector you need the following:

  • Have a AWS account. SQS provides. If you are using free tier account you have 1,000,000 requests of Amazon Simple Queue Service
  • Have AWS identity and access management credentials. These credentials comprise of Access key and secret key.

Demo Application

We have created an Amazon SQS Queue. We will be first sending and then receiving messages from Amazon SQS. In this application,  In first flow we will first be creating a queue and then we will be sending messages to queue. We need to first create an SQS configuration. In the configuration we provide accessKey, secretKey, region and queueUrl. We get accessKey and secretKey from IAM credentials. 

We are using HTTP listener to create and send messages to the queue. We further are using SQS Read connector to read messages. We can also use SQS Receiver as an inbound endpoint to receive messages. 

Project Snapshot

Transform Message Component for Sending Message

Message to be send to SQS Queue

Messages pushed to SQS Queue

Description

Message send to SQS is send in the specific format as shown above. It is send as a Java object with the properties defined in it and message is send as String. SQS queue has higher availability and there are many operation present in mule connector that can be done. We can further create FIFO or Simple Queue depending on our requirement. SQS is easy to use and implement and widely used queuing system

SQS Use Case

SQS can act as message queuing system just like Active MQ. SQS can be used as message queuing system for maintaining reliability of messages and forming a reliability pattern. Suppose there are no of users hitting a process api which further hits the system api. In the meantime system api gets down or is not available. If there is no reliability pattern in place the messages could get lost. Here SQS can provide reliability of messages by adding sending messages to SQS that have come from HTTP Request in order to maintain reliability. Here the messages coming from HTTP Listener are first send to queue instead of directly calling system api. 

Once the messages are send to SQS, SQS Receive connector receives messages, transforms it and send it to the System API. This way we maintain reliability of message

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.