I am sending messages to Service Bus Topic from Azure Functions, and when the function is called for the first 3-4 times, it takes around 10-20 seconds to send message to Service Bus Topic, and I am looking ways to reduce this time, I am sending message to service bus using below code.
public class ServiceBusTopicService
{
private static ITopicClient _topicClient;
public ServiceBusTopicService(string serviceBusConnectionString, string topicName)
{
_topicClient = new TopicClient(serviceBusConnectionString, topicName);
}
private static async Task SendMessage(string json)
{
var message = new Message(Encoding.UTF8.GetBytes(json));
await _topicClient.SendAsync(message);
}
public async Task BroadCastEvent(string matasId, Guid correlationId, string profileSource, string eventType)
{
var eventToPost = JsonConvert.SerializeObject(ProfileEvent.GetProfileEvent(matasId, correlationId, profileSource, eventType));
await SendMessage(eventToPost);
}
}