How to make Eventhub Consumer resilient?

Shruti 40 Reputation points
2025-03-26T12:41:58.8733333+00:00

I am building a consumer application(Spring boot application running on AKS) that consumes and processes events from Azure Event Hub topics (Enterprise solution hosted on a different subscription) and updates data in a database.

Note: Eventhub is currently the chosen solution, so we can't change it.
Currently, the consumer application is able to consume events and process them in the happy path, but in case of failures, I have only implemented a retry and skip logic.

I want the solution to be more resiliant in a way that I can store messages that I have consumed but not processed (issues with updating the database) or in case of not being able to process the incoming event (serialisation errors) . My application is idempotent and has a way to handle duplicate or out of sequence messages based on timestamps.

Or any such circumstances.

I need a pattern like DLQ to automatically route failed messages to a queue.

I have seen patterns where I can use the try-catch method to route messages to another event hub or service bus queue, but I am not sure if it will handle all edge cases like De-serialisation issues.

Can I have a Service Bus between my Eventhub and AKS application?

Eventhub -> Service Bus -> Consumer Application

The Service Bus will have a built-in DLQ. I can use it with Azure Functions or Logic apps to deal with failed messages.

We consume around around 4-5k messages per day across 4 different eventhub topics.

What are some other cost-friendly options?

Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
711 questions
0 comments No comments
{count} votes

Accepted answer
  1. Smaran Thoomu 23,095 Reputation points Microsoft External Staff Moderator
    2025-03-26T15:02:11.7833333+00:00

    Hi @Shruti

    To address your concerns about making your Event Hub consumer more resilient, here are specific recommendations:

    Handling unprocessed messages due to database failures:

    • Since your application is idempotent, you can store unprocessed messages in a retry queue (e.g., an Azure Service Bus queue or Blob Storage).
    • A background job (Azure Function or Logic App) can retry processing messages periodically.

    Handling deserialization errors

    • If an event cannot be deserialized, route it to a Dead Letter Queue (DLQ).
    • You can create a separate Event Hub or Service Bus queue to store these failed events for debugging and reprocessing.

    Using Service Bus between Event Hub and the Consumer (Event Hub → Service Bus → AKS Consumer)

    • Yes, this is a valid approach. Service Bus has a built-in DLQ** and supports retries.
    • However, adding Service Bus increases cost and complexity. If buffering is not required, consider logging failed messages instead.

    Cost-friendly alternatives

    • If your main concern is failed messages, a separate Event Hub DLQ or Blob Storage is more cost-effective than Service Bus.
    • If failures are rare, you can log messages in Cosmos DB or Blob Storage and retry them later.

    Suggestions:

    1. If event buffering is needed → Service Bus works well.
    2. If you just need a DLQ → A separate Event Hub or Blob Storage is more cost-effective.
    3. If failures are rare → Logging failed events for later analysis is the cheapest option.

    I hope this information helps. Please do let us know if you have any further queries.

    Kindly consider upvoting the comment if the information provided is helpful. This can assist other community members in resolving similar issues.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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