-1

EventHub consumer need to process the message it received until it succeeds during the transient faults, how to achieve this infinite retry by honoring the EventHub partition lease expiry?

Here the business scenario is not important but the approach for infinite retry (by considering partition lease expiry) is what I'm looking for.

Note: I'm reading the message in batches, processing of any message can encounter transient faults which need to retry. So driving some logic with an 'offset' value may not be efficient but not sure anyone has achieved infinite retries by leveraging offset value.

Shaik Subhan
  • 284
  • 1
  • 10
191180rk
  • 735
  • 2
  • 12
  • 37
  • I am not familiar enough with the Azure services, but as far as I know most of the client SDKs have some built-in retry support. If that's the case then why do you want to use Polly? – Peter Csala Jan 17 '23 at 06:15
  • yes you can try polly "WaitAndRetryForeverAsync" but the issue with this approach is partition lease will expire after certain time. – 191180rk Jan 17 '23 at 08:17
  • If a certain exception or status code is received whenever there was *a partition lease expiry* then you can define your policy in a way that it should **not** trigger for that (~ an exit condition). Do you know what exception or status code is the expected response in that case? – Peter Csala Jan 17 '23 at 08:21

1 Answers1

1

The consumer can retry on transient failures indefinitely until cancellation is requested. By the way, the lease won't expire due to retry possibly taking longer than expected.

Please check the API documentation for more reference. https://learn.microsoft.com/en-us/dotnet/api/azure.messaging.eventhubs.processor.processeventargs?view=azure-dotnet

CancellationToken
A CancellationToken to indicate that the processor is requesting that the handler stop its activities. If this token is requesting cancellation, then either the processor is attempting to shutdown or ownership of the partition has changed.

Serkant Karaca
  • 1,896
  • 9
  • 8
  • @ serkant, so what are the valid criteria for lease partition to expiry? when EventHub transfer the partition ownership to other available processor instance? – 191180rk Jan 18 '23 at 04:50
  • I'm using Microsoft.Azure.WebJobs.EventHubs SDK, is you above statement still valid? – 191180rk Jan 18 '23 at 10:50
  • No; Functions has it's own hosting model and controls the length of time that individual Function invocations can execute. This varies by SKU; in the standard tier this is currently 5 minutes. If you need infinite time, you'll either need to use a host platform other than Functions or investigate the dedicated tier. – Jesse Squire Jan 18 '23 at 15:02