ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 34 - AZ-204 discussion

Report
Export

A company is implementing a publish-subscribe (Pub/Sub) messaging component by using Azure Service Bus. You are developing the first subscription application.

In the Azure portal you see that messages are being sent to the subscription for each topic. You create and initialize a subscription client object by supplying the correct details, but the subscription application is still not consuming the messages.

You need to ensure that the subscription client processes all messages.

Which code segment should you use?

A.
await subscriptionClient.AddRuleAsync(new RuleDescription(RuleDescription.DefaultRuleName, new TrueFilter()));
Answers
A.
await subscriptionClient.AddRuleAsync(new RuleDescription(RuleDescription.DefaultRuleName, new TrueFilter()));
B.
subscriptionClient = new SubscriptionClient(ServiceBusConnectionString, TopicName, SubscriptionName);
Answers
B.
subscriptionClient = new SubscriptionClient(ServiceBusConnectionString, TopicName, SubscriptionName);
C.
await subscriptionClient.CloseAsync();
Answers
C.
await subscriptionClient.CloseAsync();
D.
subscriptionClient.RegisterMessageHandler(ProcessMessagesAsync, messageHandlerOptions);
Answers
D.
subscriptionClient.RegisterMessageHandler(ProcessMessagesAsync, messageHandlerOptions);
Suggested answer: D

Explanation:

Using topic client, call RegisterMessageHandler which is used to receive messages continuously from the entity. It registers a message handler and begins a new thread to receive messages. This handler is waited on every time a new message is received by the receiver.

subscriptionClient.RegisterMessageHandler(ReceiveMessagesAsync, messageHandlerOptions);

Reference:

https://www.c-sharpcorner.com/article/azure-service-bus-topic-and-subscription-pub-sub/

asked 02/10/2024
Scott Whitney
43 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first