Exam-Answer

Home / Microsoft / AZ-300 / Question 121

Prev Question
Next Question

Question 121

You create a Service Bus namespace named company1 with a topic named orders. The topic contains subscriptions that are shown in the exhibit.

You need to determine what happens when the code in the exhibit is run.

Exhibit:

Service bus Topic Overview Page:

Name: orderEmailer, Status Active, Message count: 10

Name: orderProcessor, Status Active, Message count: 10

Code:

static void RetrieveMessage(string connectionString, string entityPath)

{

var client = new SubscriptionClient(connectionString, entityPath, "orderEmailer");

client. RegisterMessageHandler(async (msg, token) =>

{

await client.CompleteAsync(msg.SystemProperties.LockToken);

}, new MessageHandlerOptions((args) =>

{

return Task.CompletedTask;

}));

}

Choose all that apply:

Answers



A B C

Advertisement

Explanation

SubscriptionClient.CompleteAsync is called 10 times. When you use SubscriptionClient to retrieve messages from a Service Bus topic, all the messages in the associated subscription are retrieved and removed. The RegisterMessageHandler method is responsible for assigning a delegate that gets called whenever a message is available for retrieving. In this scenario, that delegate is an anonymous method that calls SubscriptionClient.CompleteAsync. Because there are 10 messages, the anonymous method is called 10 times, resulting in SubscriptionClient.CompleteAsync being called 10 times.

No message is removed from the orderProcessor subscription. The SubscriptionClient constructor accepts as its third parameter the name of the subscription for which messages should be retrieved. Only messages in that subscription are retrieved and removed.

Ten messages are removed from the orderEmailer subscription. When you use SubscriptionClient to retrieve messages from a Service Bus topic, all the messages in the associated subscription are retrieved and removed. The RegisterMessageHandler method is responsible for assigning a delegate that gets called whenever a message is available for retrieving. Because there are 10 messages, 10 are retrieved and removed.

References

Comments

Load more
Prev Question
Next Question