FixedDelayRetry locking up the Function

krishna572 876 Reputation points
2022-06-28T00:14:22.323+00:00
   CSharp  
   [FunctionName("FixedDelayRetryTest")]  
   [FixedDelayRetry(5, "00:01:00")]  
   public void Run(  
       [ServiceBusTrigger("Topic", "Subscription", Connection = "ServiceBusConnString")] string item,  
       ExecutionContext context,  
       ILogger log  
   )  
   {  
       log.LogInformation($"Function executed at: {DateTime.Now}");  
     
       throw new System.Exception("Error Happened!!");  
   }  

While testing the FixedDelayRetry Mechanism of Azure Function (v3 - .NET Core 3.1),

Getting stuck in the scenario like the Function won't process the next message until the function consumes all the remaining retries and that message ends up in the deadletter queue!

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,231 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,222 questions
0 comments No comments
{count} votes

Accepted answer
  1. MughundhanRaveendran-MSFT 12,421 Reputation points
    2022-06-28T10:26:46.263+00:00

    Hi @NFSCoder-9821 ,

    You are seeing this behavior because you are throwing exception in the code. Please throw the exception in the catch block so that you dont encounter the retries.

    [FunctionName("FixedDelayRetryTest")]
    [FixedDelayRetry(5, "00:01:00")]
    public void Run(
    [ServiceBusTrigger("Topic", "Subscription", Connection = "ServiceBusConnString")] string item,
    ExecutionContext context,
    ILogger log
    )
    {
    try
    {
    log.LogInformation($"Function executed at: {DateTime.Now}");
    }
    catch
    {
    throw new System.Exception("Error Happened!!");
    }

    }

    0 comments No comments

0 additional answers

Sort by: Most helpful