How Azure Service Bus Queue delivers messages to client on HTTPs mode(Azure Service Bus队列如何在HTTPS模式下将消息传递到客户端)
问题描述
我们在应用程序中对Azure Service Bus队列使用HTTPS模式。
ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Https;
但我们不确定Azure Service Bus如何以HTTPS模式传递消息,如果Service Bus客户端使用轮询,轮询到Azure Service Bus队列的频率。
我们使用Package:
Microsoft.ServiceBus;
Microsoft.ServiceBus.Messaging;
推荐答案
我们似乎没有任何有关这方面的官方文档。然而,大多数Service Bus客户端使用长轮询,这意味着它们打开到Service Bus的连接,并使其保持打开状态,直到它们接收到数据。如果收到消息,则客户端处理该消息并打开新连接。如果连接超时,客户端将在增量回退期后打开新连接。According to the product team,超时时间设置为30秒。
您可以使用此测试程序来查看消息在发送到队列后需要多长时间才能收到。它当前设置为一次运行一条消息。通过使用批处理,总吞吐量可能比本例高得多。
在我的机器上,消息通常在被放入队列后100毫秒内被检索到。如果我将休眠时间设置为一个更大的间隔,则检索所需的时间会稍微长一些,因此增量后退是有效的。如果音量较低,则可能需要稍长一点的时间才能收到留言。
class Program
{
private static readonly string connectionString = "";
private static readonly int sleepTime = 100;
private static readonly int messageCount = 10;
static void Main(string[] args)
{
ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Https;
var client = QueueClient.CreateFromConnectionString(connectionString, "testqueue");
client.PrefetchCount = 1;
var timeCheck = DateTime.UtcNow;
client.OnMessage((message) =>
{
var timing = (DateTime.UtcNow - message.EnqueuedTimeUtc).TotalMilliseconds;
Console.WriteLine($"{message.GetBody<string>()}: {timing} milliseconds between between send and receipt.");
});
for (int i = 0; i < messageCount; i++)
{
client.Send(new BrokeredMessage($"Message {i}"));
Console.WriteLine($"Message {i} sent");
Thread.Sleep(sleepTime);
}
Console.WriteLine("Test Complete");
Console.ReadLine();
}
}
这篇关于Azure Service Bus队列如何在HTTPS模式下将消息传递到客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Azure Service Bus队列如何在HTTPS模式下将消息传递到客户端


- 输入按键事件处理程序 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01