i’ve spent way too much time with chatgpt trying to clarify this but dont get it. I might be being a bit slow here.
i produce an purchase message with customer 444 as the group id, then
i produce an invoice message with customer 444 as the group id
and the invoice comes before the purchase, how does sqs know to wait for the purchase message? chatgpt just keeps saying “oh sqs just knows the purchase is supposed to come first”
It doesn’t. The message group Id puts the messages into different lanes, and then it processes the messages within each lane in the order they arrived, so if you send the invoice message first, the invoice will be processed first.
If my coworker asked that, my response would be something like: instead of asking the chat you could spend that time reading the docs. Also why wait? You can process purchase and invoice separately, as it pours from the sqs in whatever order
There might be demands within the receiving ERP that the purchase order needs to be created before the invoice is created, but that should be solved in another way than fifo-queues.
Even better, have the chat generate some test code and actually test the documented behavior for you. This isn’t some complicated edge case and the LLMs + their corresponding wrappers just aren’t that good at even a moderate understanding of how the major CSPs work as it stands today.
I would rephrase “if you send the invoice message first, the invoice will be processed first” to “if the invoice message is received by SQS first then the invoice will be processed first.”
i read the documentation and then ran through some examples w/ chat and it gave me some confusing answers. this is why i’m here. as was mentioned in another comment there are various reasons in different types of events where order matters. also why we’re looking at FIFO
I cannot tell you how exactly it’s works internally in SQS but you can read how order guarantees are done in Kafka or ActiveMQ.
Usually a metadata service/logic is involved which tracks the order of messages and its consumption. And with distributed system same data is replicated using different algorithms.
Yeah fifo is cool, but still risky. What if a message doesn’t reach the queue, or in any way the order is wrong? What about retries, dlq? Are orders and invoices on the same queue? Smells like state. Maybe split them into two. Emit order, process order, emit invoice, process invoice. Dunno, a lot of possibilities how to solve this on aws for different infras. Lambdas, dynamo, events, what are you doing step functions, sns… The aws architecture blog might help a bit.