Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to understand Azure Service Bus Sessions

So I am trying to understand Azure service bus Session ID for creating FIFO in my queue.

The idea I have is pretty straight forward but I don't know if its the right way to thing when it comes to FIFO.

What i am thinking are in these steps fro creating FIFO in my queue:

TO CREATE:

First: Check the Queue for messages and their Session ID's to and expose the ID hierarchy.

Next: Create new message with the the latest Session-ID in the hierarchy and iterate that value by 1 (+1)

Next: Send to Service Bus Queue.

TO READ:

First: Check the Queue for messages and their Session ID's to and expose the the ID hierarchy.

Next: Read-And-Delete the earliest Session-ID in the hierarchy.

Next: Process...

Keep in mind I haven't included error handling and such for example the read-and-delete part, because that I have already figured out.

So the question is is this the right way of thinking and also, how do I achieve this in C# I cant really find something that explains this concept in a straight forward manner.

like image 381
John Avatar asked Dec 06 '22 13:12

John


1 Answers

To elaborate:

Lets say you have 9 total queue messages and these are grouped into three sessions, session ids 1, 2, and 3. Each group of 3 messages will then be processed in order (First in first out).

However, parallelism can still occur between sessions - or between each group of messages - if there is more than one queue listener.

Each listener/processor of the queue storing all 9 messages gets a lock on all the messages that share the same session id and then processes each message one at a time until the session is complete (usually when there are no more messages left in the queue with that session id unless you turn off AutoComplete and decide to manually close the session whenever you deem it necessary).

Hopefully that makes sense.

like image 115
boylec1986 Avatar answered Jan 01 '23 02:01

boylec1986