1
votes

I have a client that pushes messages into a Service Bus. I have an Azure Function on the other side that is bound to the Service Bus so that it is automatically called when a message is posted in the Service Bus.

(Client) ---Message---> (Service Bus) ---Message---> (Azure Function)

The Service Bus guarantees that the first message in the queue will be the first to get out (FIFO).

Now, I assume that, under a certain load, several Azure Functions will be started to process the messages from the Service Bus.

Let's say one of these Azure Functions crashes (for whatever reasons) and is unable to process a message.

Question

Does the Service Bus put back the unprocessed message back in the first place and does that mean that, technically, even if this message was the first in the queue, it can indeed be processed after a more recent message?

1

1 Answers

3
votes

You need to properly set the SessionID to guarantee order. For session-aware entities, this application-defined value specifies the session affiliation of the message. Messages with the same session identifier are subject to summary locking and enable exact in-order processing and demultiplexing. For session-unaware entities, this value is ignored. See Message Sessions.

https://docs.microsoft.com/en-us/azure/service-bus-messaging/message-sessions