Reputation: 974
I have ServiceBusTrigger
for ServiceBusQueues.QUEUE_NAME
[Function(nameof(QueueProcess))]
public async Task QueueProcess([ServiceBusTrigger(ServiceBusQueues.QUEUE_NAME, Connection = "ConnectionString")] string message)
{
try
{
Console.Write(message);
}
catch (Exception ex)
{
throw;
}
}
Whenever I send a message there it retries it 10 times and moves the message to Dead-Letter.
There's no error, function finishes successfully.
I know that behavior like this could happen because of reasons described under Max Delivery Count.
Please suggest, what could cause ServiceBusTrigger
not to complete the message and keep retrying it even when there's no error?
Upvotes: 0
Views: 477
Reputation: 1301
In ServiceBusTrigger we can set Autocomplete as True. This helps us in completing the task without sending it to deadletterqueue. In most cases it will be as default.
When set to false, you are responsible for calling MessageReceiver methods to complete, abandon, or deadletter the message. If an exception is thrown (and none of the MessageReceiver methods are called), then the lock remains. Once the lock expires, the message is re-queued with the DeliveryCount incremented and the lock is automatically renewed.
We need to check that we installed an extension as "Microsoft.Azure.WebJobs.Extensions.ServiceBus" is more than 4.3.0
Here, the function will invoke, it will try to process the same message twice and on the third time it put the message into the Dead Letter Queue (DLQ). You can manually check the contents of the DLQ via the Azure Portal.
Refer to the blog for more understanding in managing servicebustrigger and about host settings
Upvotes: 1