Azure / Azure/azure-functions-host

[ServiceBusTrigger] AutoComplete on a case-by-case basis?

Open
#6,183 13 comments 0 reactions 0 assignees View on GitHub
Needs: Attention :wave:
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

#### Is your question related to a specific version? If so, please specify:
Microsoft.NET.Sdk.Functions 3.0.7
Microsoft.Azure.WebJobs.Extensions.ServiceBus 4.1.1

#### What language does your question apply to? (e.g. C#, JavaScript, Java, All)
C#

#### Question
Is it possible to have `AutoComplete` enabled, but still take manual control over it in some functions?

In general, I'm fine with having `AutoComplete` to true, but I have some long-running functions that can run for longer than the lock duration, so I want to take explicit control of the message. Currently, I defer the message before I begin the actual work, and when I'm done, I retrieve the deferred message and complete it. This works, but I get an error after the message at the end of my function:

```
[08/06/2020 07:42:35] Executed 'MyFunction' (Succeeded, Id=fbd1d739-1b77-4ce3-99c7-cbae8cfae62b)
[08/06/2020 07:42:41] Message processing error (Action=Complete, ClientId=MessageReceiver3my-queue, EntityPath=my-queue, Endpoint=my-sb-namespace.servicebus.windows.net)
[08/06/2020 07:42:41] Microsoft.Azure.ServiceBus: The lock supplied is invalid. Either the lock expired, or the message has already been removed from the queue, or was received by a different receiver instance.
```

I think this is because the function host tries to complete the message, which has already been completed.

Is it possible to disable AutoComplete for a specific function?

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the ServiceBusTrigger and AutoComplete behavior described for Microsoft.Azure.WebJobs.Extensions.ServiceBus 4.1.1, including how the function host completes messages after execution. Confirm whether per-function manual completion is supported and identify the configuration or documentation entry point that defines the expected behavior. Done means the supported approach is clear and the duplicate completion error is addressed or explicitly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, cloud
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.