Dinusha
Dinusha

Reputation: 716

How to complete the message in azure service bus

I am using Azure function app for listing to azure service bus message queue.

I want to turn off autocomplete of the message and need to decide to completion programmatically. I manage to turn off autocompletion by updating the host.json as follow.

{   "version": "2.0",   "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[1.*, 2.0.0)"   },   "extensions": {
        "serviceBus": {
            "messageHandlerOptions": {
                "autoComplete": false
            }
        }
    } }

My question is How do I complete the message delivery. What is the method I should invoke? I am writing Azure function app in javascript.

Upvotes: 1

Views: 1980

Answers (1)

AntonK
AntonK

Reputation: 2310

Call message.Complete().

e.g. Your service bus trigger looks like this:

[FunctionName("MyFunctionFQ")]
public static async Task Run([ServiceBusTrigger("%MyQueueName%", AccessRights.Listen, Connection = "SBConnection")]BrokeredMessage message, TraceWriter log) 
{
    // do your processing.....

    // complete the message
    message.Complete();
}
    

Upvotes: 1

Related Questions