Is Azure Service TopicClient Thread Safe & Reusable? Is Azure Service TopicClient Thread Safe & Reusable? azure azure

Is Azure Service TopicClient Thread Safe & Reusable?


Can topicClient be converted into Singleton & reused across multiple threads?

Yes, that's the recommended practice. From Best Practices for performance improvements using Service Bus Messaging

Service Bus client objects, such as QueueClient or MessageSender, are created through a MessagingFactory object, which also provides internal management of connections. You should not close messaging factories or queue, topic, and subscription clients after you send a message, and then re-create them when you send the next message. Closing a messaging factory deletes the connection to the Service Bus service, and a new connection is established when recreating the factory. Establishing a connection is an expensive operation that you can avoid by re-using the same factory and client objects for multiple operations. You can safely use the QueueClient object for sending messages from concurrent asynchronous operations and multiple threads.