Why Amazon SQS?
amazonsqs

Introduction

Amazon Web Services provides many services to make life easier. “Amazon SQS” is another service provided by Amazon for handling the messages in a queue. Amazon SQS (Simple Queue Service) offers a very durable and secure available hosted queue that lets you integrate and decouple distributed software systems and components. It provides a generic web services API, and is accessible by any programming language that the AWS SDK supports.

In this Distributed messaging system, there are three main parts: the components of distributed system, the queue, and the messages in the queue.
Note: Amazon SQS automatically deletes those messages that have been in a queue for more than a maximum retention period. The default retention period of the message is 4 days.

​​​​​​​There are two types of queues:

  • SQS
  • MQ

Prerequisites

  • AWS Login Credentials
  • Need permissions to IAM role to access SQS

Difference Between Amazon SQS and Amazon MQ

Amazon SQS is highly scalable, simple to use. It does not require you to set up message brokers. These services are used for new applications that can benefit from nearly unlimited scalability and simple APIs.

Amazon MQ (Message Queue) is used for migrating apps from the initial message brokers that rely on protocols like MQTT, AMQP, and OpenWire. It is a properly managed and compatible message broker service.

Benefits of Amazon SQS

  • SQS is more secure because it uses Server-Side Encryption (SSE) that allows you to transmit sensitive data by protecting the contents of messages in queues.
  • SQS can process each buffered request in the queue independently and scale transparently to handle any kind of load increases.
  • Amazon SQS uses the redundant infrastructure for producing, accessing, and consuming messages to ensure zero data loss and high availability. This infrastructure is based on three parts; producers, consumers, and the queue. The queue stores message redundantly across multiple servers for high availability.
  • Amazon SQS stores the messages on multiple servers to ensure the safety and keep the messages durable.
  • Your messages will be locked during processing so that multiple producers and consumers can work simultaneously or can send or receive messages at the same time to maintain reliability.
  • SQS queues are customizable, i.e. user can set a delay by default on its queue and store the messages of size more than 256 KB by configuring it with Amazon S3.

Getting started with AWS SQS

You can perform the following action in SQS

  • Create New Queue
  • View/Delete Messages
  • Delete Your Queue

Create New Queue

The Amazon SQS supports two types of queues:

  1. Standard Queue
  2. FIFO Queue
  • To create a new queue, select any one queue type (we are creating a FIFO queue in our example), then enter the name of your new queue and click on “Quickly Create Queue” button.
    Please make sure that you are in the correct region.

    Note: The FIFO queue name should end with the “.fifo” suffix.
    Example: zentech_queue.fifo

  • The “Queue Type” column will display the type of your queue – Standard or FIFO. Select the checkbox of your queue to see the description. For e.g. URL and ARN of your queue with other details.

Send a Message

  • Select the checkbox of the newly created queue and click on the Queue Actions button. Select “Send a Message” option from the drop-down menu.
  • Enter the text message you want to send along with Message Group ID and Message Description ID. Click on the “Send Message” button to send the message into the queue.

    Note: For FIFO Queues, the Message Group ID and Message Description ID are mandatory.

a screenshot of a cell phone
  • After sending the message, the screen will prompt you to the sent message attributes.
a screenshot of a cell phone

View/Delete Messages

  • Select the checkbox of the newly created queue and click on the Queue Actions button. Select “View/Delete Messages” option from the drop-down menu.
  • Click on “Start Polling for Messages” button.
a screenshot of a social media post
  • It will start polling and fetch the messages in the queue.
a screenshot of a social media post

To delete any message, enable the checkbox of the message from the queue then click on “Delete Message”.

A pop-up window will appear, click on “Yes, Delete Checked Messages” button to delete the selected messages.

Note: You can select more than one message at a time.

Delete the Queue

  • Select the checkbox of the queue and click on the Queue Actions button. Select “Delete Queue” option from the drop-down menu.
  • Click on the “Yes, Delete Queue” button form the confirmation pop up window.

Conclusion

In the above document, we have created a new SQS queue based on FIFO and send the message. Then we have received that message and deleted it successfully!
In the end we have deleted our SQS FIFO queue.

Related Posts