An e-prescribing platform processes medical prescriptions using an Azure Service Bus queue named `prescription-processing`. You are writing a C# console application that retrieves these prescriptions and updates a database. Because patient safety is critical, the application must guarantee that if a receiver crashes or encounters an unhandled exception while processing a prescription, the message is not lost and becomes available again for other receiver instances to process.
You write the following code segment to initialize the receiver and handle incoming messages:
csharp
string connectionString = "Endpoint=sb://...";
string queueName = "prescription-processing";
await using var client = new ServiceBusClient(connectionString);
var options = new ServiceBusReceiverOptions
{
// Line X
};
ServiceBusReceiver receiver = client.CreateReceiver(queueName, options);
ServiceBusReceivedMessage message = await receiver.ReceiveMessageAsync();
try
{
await ProcessPrescriptionAsync(message);
// Line Y
}
catch (Exception)
{
// Line Z
}
Which set of code segments should you use to complete the implementation?
- ALine X: ReceiveMode = ServiceBusReceiveMode.ReceiveAndDelete
Line Y: // No action required
Line Z: // No action required - BLine X: ReceiveMode = ServiceBusReceiveMode.ReceiveAndDelete
Line Y: await receiver.CompleteMessageAsync(message);
Line Z: await receiver.AbandonMessageAsync(message); - Line X: ReceiveMode = ServiceBusReceiveMode.PeekLock
Line Y: await receiver.CompleteMessageAsync(message);
Line Z: await receiver.AbandonMessageAsync(message);Answer - DLine X: ReceiveMode = ServiceBusReceiveMode.PeekLock
Line Y: await receiver.AbandonMessageAsync(message);
Line Z: await receiver.CompleteMessageAsync(message);