After sending message to Topic, why to use the TopicClient.Close()
or CloseAsync()
method? What purpose is it? What if it does not call the Close()
method after sending message?
Asked
Active
Viewed 929 times
2

Samuel
- 51
- 6
-
1I think you should review your question and clarify what API you are actually asking about. Are you sure there is a method `Close` on `TopicClient`? Have you done any research using the usual resources out there? If so, tell us. – Jun 04 '18 at 15:18
1 Answers
2
When producing messages, you would typically retain a long lived TopicClient
to send more than one message, since when operating in AMQP or SBMP modes, keeping the client open will retain long lived connections to the broker. AMQP / SBMP modes are typically recommended over HTTP for performance reasons.
(In fact, you may even share the TopicClient instance amongst threads since it's threadsafe)
Why to use the TopicClient.Close() or CloseAsync() method
i.e. you would only use the sync or async Close methods only when your application had no further use for the TopicClient, for instance when your application is exiting - this would be a graceful way to disconnect from the topic.

StuartLC
- 104,537
- 17
- 209
- 285