I'm planning to use an AWS SQS FIFO queue with my application, which queue gets messages from an SNS FIFO topic. The queue provides the messages in first-in-first-out order. What is not very clear to me by documentation is what does this mean for the ordering of the Records array provided to the lambda's handler function when receiving batches of messages from the queue.
Is the item in that array with the highest index number the first item that was sent through SNS+SQS? And the lowest index number is the newest item? This would be my guess based on the logic the first item off the array would be the one you get when you call pop on the array. You get the item with the highest index number. So this would be the "first out" item. Or if I loop through the array from the start of the array with forEach, I get the newest message first?
I just didn't find confirmation for this in docs and the times on the message metadata for my test messages are the same due to batching and how fast they go through SNS. There is also a SequenceNumber on the messages which is higher for the item with the higher index number, which I'm not sure what to make of.
I tested this. From an SQS FIFO queue the events are provided to lambda in the Records array in the lambda handler function argument in such order that the "first in" item is the one that has the lowest index number so the array is [oldest, newer, newest]. I guess that makes sense, just needed to be sure.