0

I have Azure function running on QueueTrigger, but would like to complete the function without sending the message to poison queue if DequeueCount(max retries) exceeds the set limit (but keep sending other failed messages to the poison queue)

My current function looks like this:

public async Task ProcessThis([QueueTrigger("message-queue")] Message message, string id, string popReceipt, int dequeueCount, ILogger logger)
{
   try
   {
     ...
     //process queue here
     ...
   }
   catch (Exception e)
   {
     if (dequeueCount == this._config.DequeueCount) //Currently it's set to 10
     {
       return; //If I return here, would the message still go into poison queue?
     }

     throw e;
   } 
}

I want to know if this is the correct way to prevent the message going into poison queue if it fails due to max retry exceeds.

2 Answers 2

2

If the function does not throw an exception, Azure Function Runtime treats that as a successfully processed message and remove it from the Q.

If you throw any sort of exception then Runtime considers it a failure and increments dequeue count. If the new count is beyond maxDequeueCount it is moved to poison Q. See doc.

So if you just don't want anything to goto poison Q, simply add a catch-all block to your ProcessThis() and suppress the exception.

Sign up to request clarification or add additional context in comments.

Comments

0

Not sure what the max queue count is but this article has a handy work around. Just

requeue the message. You could also subscribe to the poison queue, and just requeue it

1 Comment

difference between re-queuing the message and throwing an exception to make Function Runtime to do it for you is that: If you re-queue using output binding the visibilityTimeout doens't apply, it's a new message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.