0
0
Azurecloud~10 mins

Message ordering and sessions in Azure - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Message ordering and sessions
Send messages with SessionId
Messages arrive at queue/topic
Service groups messages by SessionId
Receiver accepts a session
Messages delivered in order within session
Session state can be stored and updated
Receiver completes session processing
End
Messages are sent with a session ID. The service groups messages by this ID. Receivers accept sessions and get messages in order. Session state can be stored and updated during processing.
Execution Sample
Azure
Send message1 with SessionId='A'
Send message2 with SessionId='A'
Send message3 with SessionId='B'
Receiver accepts SessionId='A'
Receiver processes messages in order
This example shows sending messages with session IDs and a receiver processing messages in order for a specific session.
Process Table
StepActionSessionIdMessage OrderReceiver StateOutput
1Send message1A1NoneMessage1 queued
2Send message2A2NoneMessage2 queued
3Send message3B1NoneMessage3 queued
4Receiver accepts sessionA-Session A acceptedReady to receive messages
5Receiver receives message1A1Processing message1Message1 delivered
6Receiver receives message2A2Processing message2Message2 delivered
7Receiver completes sessionA-Session A closedSession processing done
8Receiver tries to receive from session BB-Session B not acceptedNo messages delivered
💡 Receiver stops after completing session A; messages in session B remain until accepted.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6After Step 7After Step 8
Queue MessagesEmptyMessage1 (A, order 1)Message1, Message2 (A, order 2)Message1, Message2 (A), Message3 (B, order 1)SameMessage2 (A), Message3 (B)Message3 (B)Message3 (B)Message3 (B)
Receiver SessionNoneNoneNoneNoneSession A acceptedSession A processing message1Session A processing message2Session A closedSession A closed
Key Moments - 3 Insights
Why does the receiver only get messages from one session at a time?
Because the receiver accepts a specific session (see Step 4 in execution_table), it processes messages only from that session to maintain order.
What happens to messages in other sessions while one session is being processed?
Messages in other sessions remain in the queue until their session is accepted by a receiver (see Step 8). They are not delivered out of order.
How is message order guaranteed within a session?
Messages with the same SessionId are delivered in the order they were sent (see Steps 5 and 6), ensuring ordered processing.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at Step 5. What message does the receiver process?
AMessage2 with SessionId 'A'
BMessage1 with SessionId 'A'
CMessage3 with SessionId 'B'
DNo message
💡 Hint
Check the 'Action' and 'Output' columns at Step 5 in execution_table.
At which step does the receiver close the session?
AStep 7
BStep 8
CStep 6
DStep 4
💡 Hint
Look for 'Session closed' in the 'Receiver State' column in execution_table.
If the receiver accepts session 'B' at Step 4 instead of 'A', what changes in the execution_table?
AMessages from session 'A' are delivered first
BNo messages are delivered
CMessages from session 'B' are delivered in order
DMessages from both sessions are delivered simultaneously
💡 Hint
Refer to how session acceptance controls message delivery order in execution_table Steps 4-6.
Concept Snapshot
Message ordering and sessions in Azure Service Bus:
- Messages sent with SessionId are grouped.
- Receiver accepts one session at a time.
- Messages within a session are delivered in order.
- Session state can be stored and updated.
- Other sessions wait until accepted.
Full Transcript
In Azure Service Bus, messages can be sent with a SessionId to group related messages. The service groups messages by this SessionId. A receiver accepts a session and processes messages from that session in the order they were sent. This ensures message ordering within the session. The receiver can store and update session state during processing. Messages from other sessions remain queued until their session is accepted. This process guarantees ordered and grouped message processing.