Hands-on Lab – Sending and Polling messages from an SQS FIFO queue
1. Click the Start Playcloud button. This will redirect you to the Queues section of the Amazon SQS.
2. To send a message, select FIFO-QUEUE-Labs.fifo > Send and receive messages button.
3. Add a message body in the Message body field.
4. Add a Message group ID and Message deduplication ID
- Message Group ID: It is utilized to cluster relevant messages. If messages are directed to an SQS queue and share the same message group ID, they are regarded as part of the same message group. This facilitates the processing of messages in a precise order, referred to as message grouping. With the ability to specify a message group ID, you can regulate the sequence in which messages are managed, assuring that messages within a particular group are handled consecutively.
- Message Deduplication ID: It is utilized to prevent the processing of duplicate messages. The Message Deduplication ID feature requires including a deduplication ID when sending a message to an SQS queue. Amazon SQS then checks if a message with the same ID has been sent within a specific timeframe, and if it has, the new message is discarded and not enqueued. This ensures that duplicate messages resulting from retries or retransmissions are not processed more than once.
5. Expand the Message attributes section. Add a “Sender” attribute with your custom name.
- If you add a “Sender” attribute with a custom name, it will help distinguish messages from different senders or match specific senders with their messages. This feature provides added context to the messages and enables the recipients to make informed decisions or take necessary actions based on the sender’s information.
- Remember that message attributes are optional and not required for basic functionality. They are there to provide additional flexibility and customization options for your messaging needs in Amazon SQS.
6. Send Message
7. Scroll down to the “Receive messages” section > click Poll for messages
- Poll for messages involves a consumer actively checking a queue for available messages to retrieve and process. This process enables the consumer to regularly fetch new messages from the queue and perform actions based on their content, facilitating real-time communication and information exchange in distributed systems.
8. After polling the messages, you will receive a confirmation message of the one you sent.
9. You can view the SQS message that you have sent, which includes the Body and custom Attributes.
10. Try to resend the message
11. After Polling the messages, you’ll notice that the message has been deduplicated.