Why doesn’t my Amazon SQS FIFO queue return all messages or messages in other message groups?
Last updated: 2021-08-26
My Amazon Simple Queue Service (Amazon SQS) First-In-First-Out (FIFO) queue doesn’t return some messages when I call the ReceiveMessage API. Why doesn’t my SQS FIFO queue return all messages from a specific message group ID or from other message groups?
For FIFO queues, you can’t request to receive messages from a specific message group ID. When you specify a MaxNumberOfMessages parameter in the ReceiveMessage API call, SQS returns as many messages with the same message group ID as possible. Other consumers or other ReceiveMessage calls can then process messages with a different message group ID.
For FIFO queues, when you receive a message belonging to a particular message group ID, note the following:
- You must delete or move messages in the current receive call before you can receive more messages from the same group ID.
Note: Messages must be moved from inflight available state.
- You can’t receive messages in other message groups.
A FIFO queue looks through the first 20,000 messages to determine available message group. If all message groups in the first 20,000 messages are blocked due to inflight messages, then messages from other groups beyond the first 20,000 won't return. For more information, see Avoid having a large backlog of messages with the same group ID.
A FIFO queue has a total of 20,001 messages. The first 20,000 messages belong to message group 1, and the last message belongs to message group 2. When you try to receive messages from the queue, you receive a message only from group 1. Any consecutive ReceiveMessage calls result in empty receives. This happens because FIFO looks through only the messages that belong to group 1, and that group is blocked by the current call.
A FIFO queue has a total of 20,000 messages. The first 19,999 messages belong to message group 1, and the last message belongs to message group 2. When you try to receive messages from the queue, the first ReceiveMessage call gets a message belonging to group 1. The second ReceiveMessage call gets a message belonging to group 2. Any additional ReceiveMessage calls result in empty receives since both groups are now blocked by the current calls.