Service Bus message abandoned despite WebJobs SDK

2019-04-12 12:21发布

I have implemented a long running process as a WebJob using the WebJobs SDK. The long running process is awaited because I want the result.

public async Task ProcessMessage([ServiceBusTrigger("queuename")] MyMessage message)
{
    await Run(message.SomeProperty); // takes several minutes
    // I want to do something with the result here later..
}

What I can't figure out is why the message sometimes is abandoned which of course triggers the handler again. I've tried to debug (locally), setting breakpoints before ProcessMessage finishes and I can see that it appears to finish successfully.

The Sevice Bus part of the WebJobs SDK takes care of message lock renewal, so that shouldn't be a problem as far as I've understood.

What am I missing and how do I troubleshoot?

1条回答
一纸荒年 Trace。
2楼-- · 2019-04-12 12:53

[Edited previously incorrect response]

The WebJobs SDK relies on the automatic lock renewals done by MessageReceiver.OnMessageAsync. These renewals are governed by the OnMessageOptions.AutoRenewTimeout setting, which can be configured like so in the v1.1.0 release of the WebJobs SDK:

JobHostConfiguration config = new JobHostConfiguration();

ServiceBusConfiguration sbConfig = new ServiceBusConfiguration();
sbConfig.OnMessageOptions = new OnMessageOptions
{
  MaxConcurrentCalls = 16,
  AutoRenewTimeout = TimeSpan.FromMinutes(10)
};

config.UseServiceBus(sbConfig);

You can also customize these values via a custom MessageProcessor. See the release notes here for more details on these new features.

查看更多
登录 后发表回答