Amazon Simple Queue Service (SQS) is a managed message queue service offered by Amazon Web Services (AWS). It is a distributed queue system that enables web service applications to quickly and reliably queue messages that one component in the application generates to be consumed by another component where a queue is a temporary repository for messages that are awaiting processing.
Using SQS, you can send, store and receive messages between software components at any volume without losing messages.
What is message queue (MQ)?
Message queueing is a method by which process (or program instances) can exchange or pass data using an interface to a system-managed queue of messages. Messages can vary in length and be assigned different types or usages. A message queue can be created by one process and used by multiple processes that read and/or write messages to the queue. For example, a server process can read and write messages from and to a message queue created for client processes.
There is lots of products available in market to implement this message queue. One of them is AWS SQS. Its a managed service for MQ.
Some Advantages of AWS SQS :
> SQS is simple to get started with and configure if you are new to using both AWS and if you are new to using this particular service.
> Pricing for SQS is surprisingly less complicated than other services in AWS and is pretty reasonable.
> SQS triggers are a game changer. They allow more robust decoupled, scalable, event-driven serverless architectures, and they also trigger some awesome side effects when used properly.
> Options for a FIFO and Standard queue, so anyone can choose on the base of their requirements.
> Has an add-on functionality of configurable parameters, like Delivery Delay, Default Visibility Timeout, Message Retention Period, Receive Message Wait Time, etc.
> Provides very good support for asynchronous processes.
> SQS allows data to be encrypted in transit, which may be required for compliance in some products.
Use cases of AWS SQS :
There are lots of usecases of AWS SQS. Some of them are :
1. Consider a sender component ‘A’ and receiver component ‘B’. Now A is sending a messages to B at a higher rate than the rate receiver B can process. This creates a serious problem of losing messages in transit.
To prevent messages getting lost, a SQS queue can be introduced to act as a buffer to prevent loss of messages. The messages are stored in the queue in transit and then delivered to the receiver.
This was one of the simplest usecase of SQS.
2. Sending notifications to a customer where order is critical. In this types of usecases, we can use FIFO queues. FIFO queues are useful for applications that depend on the order of the events and / or need message de-duplication to built into the queue itself.
3. Analyze the contents of messages delivered to a dead-letter queue to diagnose software or the producer’s or consumer’s hardware issues. The main task of a dead-letter queue is handling message failure. A dead-letter queue lets you set aside and isolate messages that can’t be processed correctly to determine why their processing didn’t succeed.
4. We can also integrate SQS with AWS Lambda and S3 and add trigger and Destination in Lambda, if any object is added to S3 bucket, It triggers Lambda, if Lambda function runs successfully, we can add SQS as destination for this, so message will be recieved by reciever in SQS. Similarly we can add trigger for failure, then some other SQS will recieve message and do some other work.