I have two very simple NodeJS based Azure function, one which pushes an event to a Service Bus queue:
import { Context } from '@azure/functions';
export async function run(context: Context, myTimer: any): Promise<void> {
context.log('Function started!');
context.bindings.taskQueue2 = [{ message: 'Some task message' }];
context.log('Function finished!');
}
and an another which reads the message, logs it's content and then exists:
import { Context } from '@azure/functions';
export async function run(context: Context, myQueueItem: any): Promise<void> {
// https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus#trigger---message-metadata
context.log('Node.js ServiceBus queue trigger function processed message', myQueueItem);
context.log('EnqueuedTimeUtc =', context.bindingData.enqueuedTimeUtc);
context.log('ExpiresAtUtc =', context.bindingData.expiresAtUtc);
context.log('DeliveryCount =', context.bindingData.deliveryCount);
context.log('MessageId =', context.bindingData.messageId);
// I have tried with both calling and not calling context.done
// context.done();
}
The related parts from my host.json
:
{
"extensions": {
"serviceBus": {
"prefetchCount": 100,
"messageHandlerOptions": {
"autoComplete": false,
"maxConcurrentCalls": 512,
"maxAutoRenewDuration": "00:10:00"
}
}
},
}
What I would expect that calling the first function once would result in:
- one message is pushed to the service bus queue (works)
- the second function would read that message (works)
- the second function would marke it as processed when exiting without error (doesn't work)
However what I see instead is the second function re-receives the message from the queue until DeliveryCount
reaches the limit.
My questions are:
- Why the task is not marked as complete automatically when the task is finished?
- How can I mark it as complete manually if messages are not marked as finished by default?