How to send Messages Between Distributed Applications in amazon simple queue service(SQS)

Here is a simple 5 steps tutorial, you will learn how to set up asynchronous messaging with Amazon Simple Queue Service (Amazon SQS). Amazon SQS is the AWS service that allows application components to communicate in the cloud. You will use the Amazon SQS console to create and configure a message queue, send a message, receive and delete that message, and then delete the queue.

Step 1. Enter the Amazon SQS Console

•The AWS Management Console will open in a new browser window, so you can keep this step-by-step guide open.  When the screen loads, enter your user name and password to get started. Then type queue in the search bar and select Simple Queue Service to open the console.

•If the SQS console landing page appears, as shown on by the screenshot, click Get Started Now. If you don't see this page, skip to the next step.

Step 2. Create an Amazon SQS Queue

In this step, you will create and configure an Amazon SQS queue. A queue is a reliable, highly-scalable buffer that stores messages as they travel between distributed applications or microservices. Queues help to decouple applications, connect microservices, batch tasks, or store notifications.
Our use case for this tutorial will simulate the storage of incoming orders from an e-commerce application.
•First, we will create a simple queue that stores orders that are placed on the store. Enter Orders in the Queue Name field.
•For this tutorial, we do not require strict ordering, so we won’t make any changes to the queue type. Leave Standard Queue selected.  
•You can configure your queue to modify settings such as retention period, maximum message size and delivery delays. For this tutorial, we will keep the default parameters. Choose Quick-Create Queue.
•Your new queue is created and selected in the queue list.

Step 3. Send Messages to the Queue

•Your queue is already selected in the list. From Queue Actions, select Send a Message. The Send a Message to Orders dialog box is displayed.
•The Send a Message to Orders dialog box is displayed. On the Message Body tab, enter the following text to represent a sample order:

1 x Widget @ $29.99 USD
2 x Widget Cables @ $4.99

•Select the Message Attributes tab to add some optional metadata about this message for easy processing. Let’s add an order type to the order. Enter Order-Type in the Name field, String in the Type field, and Online in the Value field. Click Add Attribute.

•To send the message immediately, click Send Message. Confirmation that your message was sent is displayed in the Send a Message to Orders dialog box. Click Close.

Step 4: Retrieve and Delete a Message

After you send a message to a queue, another application can consume it from the queue and do something with it. In this example, you will simply retrieve the message to view the order, and then delete it.
•Ensure that your Orders queue is selected in the queue list. Next, from Queue Actions, select View/Delete Messages.
•The View/Delete Messages in Orders dialog box is displayed. When you request a message from a queue, you don't specify request a specific message. Instead, you specify the maximum number of messages (up to 10) that you want to retrieve.

Click Start Polling for messages to retrieve messages from the queue.  

•Once a consumer has received and processed a message, it can be deleted from the queue. Select the message that you want to delete and then choose Delete 1 Message.
•The Delete Messages dialog box is displayed. Check the box next to the message and click Yes, Delete Checked Messages. The selected message is deleted. Choose Close.

Step 5: Delete the Queue
When you no longer need to use an Amazon SQS queue, we recommend that you delete the queue as a best practice.
•In the queue list, select the Orders queue. Then, from Queue Actions, select Delete Queue.

•The Delete Queues dialog box is displayed. You can still delete your queue, even though you still have messages in it. Choose Yes, Delete Queue. The queue is deleted.
SQS accepting in amazon

Congratulations!
You have created your first Amazon Simple Queue Service (Amazon SQS) message queue, sent messages to your queue, retrieved and deleted messages, and then deleted the queue. You are now ready to use Amazon SQS queues to store and move data between distributed application components and microservices.

Comments