我正在从Azure函数向Service Bus Topic发送消息,当函数被调用前3-4次时,向Service Bus Topic发送消息大约需要10-20秒,我正在寻找减少这一时间的方法,我正在使用以下代码向service bus发送消息。
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);
}
}发布于 2021-03-20 00:58:40
如果它只是在启动时,那么它很可能是cold start problem。
有关解决方案,请参阅this answer。
https://stackoverflow.com/questions/66704375
复制相似问题