- Newest
- Most votes
- Most comments
Hi,
This article details common solutions to the race condition problem that you raise: https://medium.com/@moradiyabhavik/race-condition-understanding-and-solution-926b6d2808c
This one may also be interesting for you: https://cdg.dev/tech/2020/03/avoiding-race-conditions-in-concurrent-aws-lambda-functions/
Best,
Didier
Hi Kelnor,
While leveraging SQS FIFO, you order guarantee is dependent on the the order in which the messages are published to the queue.
In your case you have mentioned "I can't guarantee these events will be generated in order and they will be asynchronous." so you need to implement a mechanism to discard/process when they arrive out of order in the consumer before persisting.
The sendMessages section in the following document captures this information https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues-understanding-logic.html
Also the messages in FIFO are ordered based on message group ID. You could for instance have the message ID as customerId, then all the messages for a given customerId is grouped and ordered within the group is preserved based on their arrival. With Lambda as a consumer, the order within the group is preserved - https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/fifo-queue-lambda-behavior.html
regards, sash
answered 2 years ago
