.net - Azure服务总线: How to Renew Lock?

标签 .net azure asp.net-core azureservicebus azure-servicebus-queues

如何更新接收队列消息处理程序上的锁? 在事件处理程序上,测试消息没有更新锁定属性。

Message testMessage;

enter image description here

https://learn.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.brokeredmessage.renewlock?view=azure-dotnet

最佳答案

目前,建议使用 Azure.Messaging.ServiceBus NuGet 包,因为 Microsoft.Azure.ServiceBus 已过时。以下是自动续订处理消息的示例代码:

var client = new ServiceBusClient(connectionString);
var processor = client.CreateProcessor(queueName, new ServiceBusProcessorOptions
{
    MaxAutoLockRenewalDuration = TimeSpan.FromHours(100),
});
processor.ProcessMessageAsync += async arg =>
{
    //process your message
    await Task.Delay(Timeout.Infinite);
};
processor.ProcessErrorAsync += async arg =>
{
    //process errors
};

关于.net - Azure服务总线: How to Renew Lock?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63585687/

相关文章:

c# - 对如何在 C# 中使用 JSON 感到困惑

c# - 如何从 C# 中的 HTTP Post 访问 header 信息?

Azure 应用服务 - 带宽限制?

azure - 在azure ARM中输出VM的私有(private)IP

c# - 配置 ASP.NET Core 应用程序的正确顺序是什么?

.net - 如何在不缩放线宽的情况下缩放路径几何以适合 View 框?

c# - 如何正确配置 Entity Framework ?

azure - 使用 Azure Functions Python 批量运行记录循环

asp.net - 在 .NET Core 2.0 DLL 中找不到入口点

c# - 在 asp.net core/kestrel 中记录异常