-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modelling SQS behaviour with non-atomic message processing #101
Comments
To mimic SQS's reservation behaviour I've limited the concurrency:
Although in practice the concurrency in my system is higher, I don't have interactions between consumers so this accurately models the system's state I think ... but open to other ideas!
|
The fundamental issue is, after processing a message, sqs_fifo.pop(0) removes the first message in the queue. But, you should actually remove the processed message from the queue. That's you'll need a message id to indicate the message that just be removed. (Sqs requires the receipthandle you got from the receive request. For simplify, you can just use the message id here) This will ensure, even if the same message was sent to the receiver twice (probably due to the visibility timeout) you delete only that message. -- In receive, , process and thensqs_fifo.remove(msg) |
I see... that would be a model that's closer to how SQS works, but I still have the same problem that if
now errors with:
|
Sorry, I just got back from vacation. Actually, you might need to atomically check if the first entry is still the msg that was processed.
Alternatively, that's could be expressed in a single line
|
Does this answer your question? |
I see.. so that will avoid the error during deletion, but would that still allow two concurrent actions to receive the same message? To avoid that I guess I need |
The following:
Will crash with:
If I use:
It won't crash, because
process
will no longer interleave withIncrement
.Is there a way to capture the reservation behaviour of SQS (ie: a message can only be received by a single consumer at a time) whilst also having a non-atomic
process
(because in practice, my system does not atomically performprocess
)?Thank you!
The text was updated successfully, but these errors were encountered: