Share via

FixedDelayRetry locking up the Function

krishna572 886 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.

Developer technologies | C#
Developer technologies | 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.

0 comments No comments

Answer accepted by question author

MughundhanRaveendran-MSFT 12,511 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!!");
}

}

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.