question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ServiceBus] Adding AutoComplete option to host.json file

See original GitHub issue

Hi there,

I’m not really sure about where I should put this kind of request. Please, let me know if I’m in the wrong place.

We have moved some code dealing with ServiceBus messages to Azure Function. In our domain, when a message failed to be processed, we move it to the DeadLetter queue. Today, given the implementation of Microsoft.Azure.WebJobs.ServiceBus.MessageProcessor supposed an Azure Function receiving the BrokeredMessage, if we move the message to the DeadLetter queue, it calls the BrokeredMessage.CompleteAsync() resulting in Exception and retries.

Here is a simple sample code to reproduce the issue:

public static class MyDequeuer
{
    [FunctionName("SampleMessageExecutor")]
    public static async Task Run(
            [ServiceBusTrigger("test-queue", AccessRights.Listen, Connection = "ServiceBusConnectionString")]
            BrokeredMessage brokeredMessage, ILogger log, ExecutionContext ctx)
    {
        await brokeredMessage.DeadLetterAsync();
    }
}

If you look at the execution, you will get the following after the Function execution.

Exception thrown: 'System.ServiceModel.FaultException`1' in Microsoft.ServiceBus.dll
Exception thrown: 'System.ServiceModel.FaultException`1' in Microsoft.ServiceBus.dll
Exception thrown: 'System.ServiceModel.FaultException`1' in Microsoft.ServiceBus.dll
Exception thrown: 'System.ServiceModel.FaultException`1' in Microsoft.ServiceBus.dll
Exception thrown: 'System.ServiceModel.FaultException`1' in Microsoft.ServiceBus.dll
Exception thrown: 'Microsoft.ServiceBus.Messaging.MessageLockLostException' in Microsoft.ServiceBus.dll
Exception thrown: 'Microsoft.ServiceBus.Messaging.MessageLockLostException' in Microsoft.ServiceBus.dll
Exception thrown: 'Microsoft.ServiceBus.Messaging.MessageLockLostException' in Microsoft.ServiceBus.dll
Exception thrown: 'Microsoft.ServiceBus.Messaging.MessageLockLostException' in Microsoft.ServiceBus.dll
Exception thrown: 'Microsoft.ServiceBus.Messaging.MessageLockLostException' in Microsoft.ServiceBus.dll
Exception thrown: 'Microsoft.ServiceBus.Messaging.MessageLockLostException' in Microsoft.ServiceBus.dll

Is there any chance to add a way to customize the AutoComplete property from MessageOptions as we can do for AutoRenewTimeout and MaxConcurrentCalls from the host.json file in an Azure Function context.

Thanks,

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:25 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
nebiyou-gebretatioscommented, Jun 24, 2018

@mathewc, basically what i want to do is manage the state myself and not rely on the function’s result. I am getting the same “The lock supplied is invalid” error that @kunalwadhwa is getting. That’s because for certain exceptions, I don’t want to retry it, but mark it as completed, while needing the function to fail so that I have a count of my failures in AppInsights.

The MessageProcessor code relies heavily on the function result. There is a chance to override that for result.Succeeded but we don’t check that failures.

Like @sescandell suggested, can’t we expose MessageOptions.AutoComplete through host.json and change to code to check that during failures too? That way, you leave the control to the user fully if they choose to do so using the MessageOptions.AutoComplete setting.

4reactions
kevin-meyercommented, Apr 20, 2018

+1 for an option where the function can be responsible of the “message lifecycle”. Maybe the consumer wants to manually defer, or forgo abandoning and letting the message stay locked for 5 minutes before being retried. The way it’s currently implemented, I’ve seen Azure functions burn through numerous retries in seconds causing messages to dead letter immediately.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Host.json settings being ignored for Service Bus in Azure ...
I have the following in my host.json file for ServiceBus ... Note that autoComplete is always false ... AutoComplete = false; options.
Read more >
Azure Service Bus bindings for Azure Functions
Learn to send Azure Service Bus triggers and bindings in Azure ... Install extension; Binding types; host.json settings; Next steps.
Read more >
Handle Azure Service Bus Messages Queue Using ...
Open the Service Bus Explorer tool, and open File menu and select Connect ... Update the host.json to set the Service Bus autocomplete...
Read more >
Consume a batch of messages in an Azure Function from ...
For our Azure Function trigger we will be using a Service Bus Topic Trigger. ... we need to add the following code to...
Read more >
Reliably Processing Azure Service Bus Topics ... - Alex Brown
This allows us to add autoComplete: false to our host.json file, which alters the way messages are handled by the function runtime.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found