191180rk
191180rk

Reputation: 905

Azure Event Hub - How to achieve infinite retry?

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.

Upvotes: -1

Views: 397

Answers (1)

Serkant Karaca
Serkant Karaca

Reputation: 2042

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.

Upvotes: 1

Related Questions