问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/33781543/renew-lock-when-using-servicebus-in-web-jobs-sdk