Is Azure TopicClient thread safe?

I deal with the Timeout thread from TopicClient, and I think this may be due to the lifespan of the object and its removal.

I use a class TopicClientfrom Microsoft.ServiceBus.Messaging, and read it at the best practice guide claims

You should not close messaging servers or queues, topics, and subscriptions after sending the message, and then re-create them when you send the next message. Closing the factory messaging removes the connection to the Service Bus service, and a new connection is established when the factory is recreated.

This is confusing to me - this document is not specifically relevant TopicClient, but I assume that it applies. Perhaps this assumption is wrong?

Can I just save my ThemeClient in a static member to avoid reconnecting the connection? Is there a better way to handle this? Is there some kind of joining mechanism that I should use instead?

+7
source share
2 answers

The documentation indicates that all static and instances of a TopicClient are thread safe.

β€œAny public static (Shared in Visual Basic) members of this type are safe thread. Instance members also guarantee thread safety.

I read the quote that you included because it specifically includes TopicClient because it says "queue clients, topics, and subscriptions." I read this as QueueClient, TopicClient and SubscriptionClient.

, , , Gateway TopicClient MessageSender/Receivers.

, MessageSender MessageReceiver? , , , , , .

+9

MS , , Best Practices :

QueueClient .

TopicClient , , TopicClient, QueueClient

+1

All Articles