0
0
Azurecloud~10 mins

Message ordering and sessions in Azure - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable sessions on an Azure Service Bus queue.

Azure
var queueDescription = new CreateQueueOptions("myqueue") { RequiresSession = [1] };
Drag options to blanks, or click blank then click option'
Afalse
Bnull
Ctrue
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Setting RequiresSession to false disables sessions and message ordering.
Using null or 0 causes configuration errors.
2fill in blank
medium

Complete the code to accept a session-enabled message receiver from the Service Bus client.

Azure
var sessionReceiver = await client.AcceptSessionAsync("myqueue", [1]);
Drag options to blanks, or click blank then click option'
Anull
B"sessionId123"
C""
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Passing null or empty string causes errors or connects to no session.
Using 0 is invalid because session ID must be a string.
3fill in blank
hard

Fix the error in the code to receive messages in order from a session-enabled queue.

Azure
var receiver = client.CreateReceiver("myqueue");
var message = await receiver.ReceiveMessageAsync();
// Fix: Use [1] to receive messages with session support
Drag options to blanks, or click blank then click option'
AAcceptSessionAsync
BCreateSessionReceiver
CReceiveSessionMessageAsync
DGetSessionReceiver
Attempts:
3 left
💡 Hint
Common Mistakes
Using CreateReceiver does not support sessions and breaks ordering.
Other method names are invalid or do not exist.
4fill in blank
hard

Fill both blanks to create a session-enabled queue and send a message with a session ID.

Azure
var queueDescription = new CreateQueueOptions("myqueue") { [1] = true };
var message = new ServiceBusMessage("Hello") { [2] = "session1" };
Drag options to blanks, or click blank then click option'
ARequiresSession
BSessionId
CMessageId
DEnableSession
Attempts:
3 left
💡 Hint
Common Mistakes
Using MessageId instead of SessionId does not assign the message to a session.
EnableSession is not a valid property.
5fill in blank
hard

Fill all three blanks to receive messages from a session and complete them after processing.

Azure
var sessionReceiver = await client.AcceptSessionAsync("myqueue", [1]);
var message = await sessionReceiver.ReceiveMessageAsync();
await sessionReceiver.[2]Async(message);
await sessionReceiver.[3]Async();
Drag options to blanks, or click blank then click option'
A"session42"
BCompleteMessage
CClose
DAbandonMessage
Attempts:
3 left
💡 Hint
Common Mistakes
Using AbandonMessageAsync instead of CompleteMessageAsync leaves the message unprocessed.
Not closing the session receiver can cause resource leaks.