- Newest
- Most votes
- Most comments
When using SendMessageBatch with an SQS FIFO queue, the success or failure of individual messages within the batch is handled independently. This means that in your scenario:
- Yes, messages A and C would be enqueued in the FIFO queue if they succeed, even if message B fails.
- Yes, message C would still be enqueued even though message B (which came before it) failed.
The batch request can result in a combination of successful and unsuccessful actions, which is why you should check for batch errors even when the call returns an HTTP status code of 200. Each message's result is reported individually in the response.
For a FIFO queue, messages within a single batch are enqueued in the order they are sent, but this applies only to the messages that successfully make it to the queue. If message B fails due to an internal SQS error, it simply won't be part of the queue, while messages A and C will be enqueued in their respective order (A followed by C).
It's important to note that this behavior is different from message processing behavior. When processing messages from a FIFO queue (for example, with Lambda), messages with the same message group ID are processed in strict order, and only one message from each group is processed at a time to maintain this sequential order. But this ordering guarantee applies only to messages that have successfully been enqueued in the first place.
So in your code example, it is indeed possible for the response to show A=success, B=failed, C=success, and in that case, only messages A and C would be in the queue (in that order).
Sources
SendMessageBatch - Amazon Simple Queue Service
SqsAsyncClient (AWS SDK for Java - 2.21.29)
Amazon SQS FIFO queue and Lambda concurrency behavior - Amazon Simple Queue Service
answered a year ago
Relevant content
asked 7 years ago
- AWS OFFICIALUpdated 3 years ago
