I am considering using Azure Service Bus
, however my question applies to queues in general.
I have a requirement to send messages in a certain order. Say that the publisher sends a message to the queue, and the subscriber receives the message, but it fails to process the message for some reason (e.g. some business rule is broken or the subscriber calls a downstream service that is down.) In that case, I cannot send subsequent messages because it would be out of order and the downstream service will return an error.
So in other words, if the subscriber fails to process message 2, I must not send message 3.
My question is - what sort of pattern can I implement to address this scenario?