Send Messages Between Distributed Applications
with HAQM Simple Queue Service (SQS)
Introduction
Implementation
1. Launch the AWS Management Console
When you click here, 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.

2. Start the HAQM SQS 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.

Create an HAQM SQS Queue
In this step, you will create and configure an HAQM 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.
1. Enter a queue name
First, we will create a simple queue that stores orders that are placed on the store. Enter Orders in the Queue Name field.

2. Choose a queue type
For this tutorial, we do not require strict ordering, so we won’t make any changes to the queue type. Leave Standard Queue selected.

3. Create the queue
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.

4.Verify queue creation
Your new queue is created and selected in the queue list.

Send messages to the Queue
Once you have created your queue, it is ready to receive messages from the online store that capture the details of each new order.
1. Send a message
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.

2. Enter message content
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

3. Enter message attributes
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.

4. Send message
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.

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.
1. View or delete messages
Ensure that your Orders queue is selected in the queue list. Next, from Queue Actions, select View/Delete Messages.

2. Poll for 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.

3. Select and delete the message
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.

4. Confirm deletion
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.

Delete the Queue
When you no longer need to use an HAQM SQS queue, we recommend that you delete the queue as a best practice.
1. Select and delete queue
In the queue list, select the Orders queue. Then, from Queue Actions, select Delete Queue.

2. Confirm deletion
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.

Conclusion
You have created your first HAQM Simple Queue Service (HAQM SQS) message queue, sent messages to your queue, retrieved and deleted messages, and then deleted the queue. You are now ready to use HAQM SQS queues to store and move data between distributed application components and microservices.
Did you find what you were looking for today?
Let us know so we can improve the quality of the content on our pages