为 Azure 服务总线会话处理器设置 WaitTimeOut
Set WaitTimeOut for Azure Service Bus Session Processor
在 Azure 服务总线 (ASB) 的旧版本中,我可以使用 SessionHandlerOptions 中的 MessageWaitTimeout 来控制 2 条消息之间的超时。例如,如果我设置超时5秒,完成第一条消息后,队列等待5秒然后选择下一条消息。
在新版本Azure.Messaging.ServiceBus中,队列必须等待大约 1 分钟才能接收下一条消息。我只需要处理一条一条的消息,不需要处理并发消息。
我遵循这个example,但找不到任何像旧版本一样设置超时的解决方案。
有人知道怎么做吗?
var options = new ServiceBusSessionProcessorOptions
{
AutoCompleteMessages = false,
MaxConcurrentSessions = 1,
MaxConcurrentCallsPerSession = 1,
MaxAutoLockRenewalDuration = TimeSpan.FromMinutes(2),
};
编辑:
我找到了解决方案。是ServiceBusClient
中的RetryOptions
var client = new ServiceBusClient("connectionString", new ServiceBusClientOptions
{
RetryOptions = new ServiceBusRetryOptions
{
TryTimeout = TimeSpan.FromSeconds(5)
}
});
对于最新的稳定版本 7.2.0,可以使用 SessionIdleTimeout property.
配置
在 Azure 服务总线 (ASB) 的旧版本中,我可以使用 SessionHandlerOptions 中的 MessageWaitTimeout 来控制 2 条消息之间的超时。例如,如果我设置超时5秒,完成第一条消息后,队列等待5秒然后选择下一条消息。
在新版本Azure.Messaging.ServiceBus中,队列必须等待大约 1 分钟才能接收下一条消息。我只需要处理一条一条的消息,不需要处理并发消息。
我遵循这个example,但找不到任何像旧版本一样设置超时的解决方案。 有人知道怎么做吗?
var options = new ServiceBusSessionProcessorOptions
{
AutoCompleteMessages = false,
MaxConcurrentSessions = 1,
MaxConcurrentCallsPerSession = 1,
MaxAutoLockRenewalDuration = TimeSpan.FromMinutes(2),
};
编辑: 我找到了解决方案。是ServiceBusClient
中的RetryOptionsvar client = new ServiceBusClient("connectionString", new ServiceBusClientOptions
{
RetryOptions = new ServiceBusRetryOptions
{
TryTimeout = TimeSpan.FromSeconds(5)
}
});
对于最新的稳定版本 7.2.0,可以使用 SessionIdleTimeout property.
配置