I am using Microsoft.Azure.ServiceBus, Version=2.0.0.0 assembly to connect to Azure Topics. The code is below
public void SendMessage(Message brokeredMessage)
{
var topicClient = new TopicClient(_configuration.ConnectionString, topicName, _defaultRetryPolicy);
await topicClient.SendAsync(brokeredMessage);
await topicClient.CloseAsync();
}
I was wondering whether it's a good practice to create the Topic Client every time I need to send a message to the topic, or should I create the Topic Client on application startup and keep using the same client every time I need to send a message?
Are there any performance or scalability issues that I need to consider?
From
Azure Service Bus Best Practices
post:Based on this, you should be reusing the
Topic Client
object.