You're implementing the first subscriber application for an Azure Service Bus topic. The portal shows that messages arrive at the subscription, and you initialized a subscription client with correct parameters, but the app still isn't consuming messages. Which code snippet will ensure the subscription client processes incoming messages?
Choose an answer
Tap an option to check your answer.
Correct answer: subscriptionClient.RegisterMessageHandler(ProcessMessagesAsync, messageHandlerOptions);.
Why this is the answer
The RegisterMessageHandler method is crucial because it sets up an asynchronous callback function (ProcessMessagesAsync) that the SubscriptionClient uses to process incoming messages from the Service Bus subscription. This method also takes MessageHandlerOptions, which configure aspects like concurrency and automatic message completion. Without registering a message handler, the client has no defined way to receive and process messages, even if they are arriving at the subscription. The other options are incorrect because: AddRuleAsync is used to define filtering rules for messages, not to initiate message consumption. new SubscriptionClient(...) initializes the client but doesn't start message processing. CloseAsync() would terminate the client's connection, preventing message consumption.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed