-1

I need to process status changes related to an entity in a sequential order. Not in parallel.

Will an SQS FIFO Group with MessageGroupId = UserId be enough?

Let's say I have the folowing messages:

  • MessageGroupId = 1, status: :pending
  • MessageGroupId = 2, status: :pending
  • MessageGroupId = 1, status: :approved

And I have 10 consumers of that FIFO Queue.

Will 1 consumer process in sequence:

  • MessageGroupId = 1, status: :pending
  • MessageGroupId = 1, status: :approved

Or can it happen that both messages are processed, in parallel - but in order -, by different consumers?

asked Mar 12, 2024 at 21:26

1 Answer 1

1

Messages are processed in the order they are received (First In First Out). Up to 10 messages can be received at once, if there are less than 10 messages with the same group ID, one can receive messages for another message group ID, but the FIFO order is maintained.

One should set the visibility time out to a value that corresponds to a time that the message takes to process. This effectively hides the message for other consumers. The default value is 30 seconds. This will reduce the chance of duplicate messages if set properly on standard queue.

Also, all queue processing should be idempotent, to account for duplicate messages because all that is guaranteed is "at least once delivery". This applies for standard queues.

For FIFO queues, there are measures in place to have exactly-once processing that one should be aware of.

https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues-exactly-once-processing.html

answered Mar 13, 2024 at 15:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.