How do you prevent out of order processing with multiple instances? If service A sends message 1 and 2, but 2 is processed faster than 1, now what?
We use notification pull to mitigate this. Queues are used for notification triggers which cause receiving services to do a REST call to the submitting service to get the current data, which could have changed already.
We use SQS which is loosely FIFO. However, there are techniques you can use in cases where ordering is strictly needed. Queue messages should contain timestamps and those timestamps can be used when inserting into your database so that even if a message is received out of order it doesn't overwrite the previously inserted message as it will have an earlier timestamp.
3
u/DJDavio Dec 13 '19
How do you prevent out of order processing with multiple instances? If service A sends message 1 and 2, but 2 is processed faster than 1, now what?
We use notification pull to mitigate this. Queues are used for notification triggers which cause receiving services to do a REST call to the submitting service to get the current data, which could have changed already.