在Web Job SDK中使用ServiceBus时更新锁定 [英] Renew lock when using ServiceBus in web jobs sdk

查看:69
本文介绍了在Web Job SDK中使用ServiceBus时更新锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用azure网络作业sdk来处理消息. ServiceBus用于消息传递.

ServiceBus消息中的最大锁定时间为5分钟,但是我的任务长时间运行,需要花费更多时间.在这种情况下,我应该调用BrokeredMessage.RenewLock,不幸的是,我没有从Web作业触发器到BrokeredMessage的访问权限(我只获取消息内容).

有人知道如何在Web作业触发器中执行RnewLock吗?

解决方案

在后台,我们使用PeekLock模式下的MessageReceiver.OnMessageAsync进行自动续订.这些由 OnMessageOptions.AutoRenewTimeout 值控制,您可以根据需要增加该值.对于JobHost,可以通过通过ServiceBusConfiguration.OnMessageOptions对其进行设置来覆盖默认的OnMessageOptions,然后在主机启动时将其传递到config.UseServiceBus()中.对于这些新选项,您应该使用最新的v1.1.0软件包,该软件包当前处于预发行版本(rc1)中,但将在一周内进行RTM.

在SDK存储库中的此处中对此问题进行了更详细的讨论. .建议通读.最新版本还为ServiceBus添加了许多扩展点,您可以使用这些扩展点来覆盖消息的处理方式.请参见发行说明中的"ServiceBus消息传递改进". >

I am using azure web jobs sdk in order to handle messages. ServiceBus is used for messaging.

Max lock time in the ServiceBus message is 5 minutes, but I have long running tasks that take more time. In this case I should call BrokeredMessage.RenewLock, unfortunately looks that I don't have access from web jobs trigger to the BrokeredMessage (I just get message content).

Does anyone know how to RnewLock in the web jobs trigger?

解决方案

Behind the scenes, we use MessageReceiver.OnMessageAsync in PeekLock mode which does do automatic renewals. These are goverened by the OnMessageOptions.AutoRenewTimeout value, which you increased as needed. For a JobHost, you can override the default OnMessageOptions by setting it via ServiceBusConfiguration.OnMessageOptions, which you can then pass into config.UseServiceBus() on host startup. For these new options, you should be using the latest v1.1.0 package which is currently in prerelease (rc1) but will RTM within the week.

This issue is discussed in more detail here in the SDK repo. Recommend reading that through. The latest release also adds a bunch of extensibility points for ServiceBus that you can use to override how messages get processed. See "ServiceBus Messaging Improvements" in the release notes.

这篇关于在Web Job SDK中使用ServiceBus时更新锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆