0

For event hub if we face a fault and the consumer crashes, then next time when it comes up how does it get to query what checkpoint it was on for the partition it gets hold of from the storage so that it can compare the reference sequence id of that message and incoming messages and process only the ones that come after that sequence id?

To save the checkpoint there is an API, but how to retrieve it?

tariq zafar
  • 659
  • 7
  • 24

1 Answers1

1

As you know that Event Hub Check pointing is purely client side,i.e., you can store the current offset in the storage account linked with your event hub using the method

await context.CheckpointAsync();

in your client code. This will be converted to a storage account call. This is not related to any EventHub Service call.

Whenever there is a failure in your Event hub, you can read the latest(updated) offset from the storage account to avoid duplication of events.This must be handled by you on your client side code and it will not be handled by the event hub on its own.

If a reader disconnects from a partition, when it reconnects it begins reading at the checkpoint that was previously submitted by the last reader of that partition in that consumer group. When the reader connects, it passes the offset to the event hub to specify the location at which to start reading. In this way, you can use checkpointing to both mark events as "complete" by downstream applications, and to provide resiliency if a failover between readers running on different machines occurs. It is possible to return to older data by specifying a lower offset from this checkpointing process. Through this mechanism, checkpointing enables both failover resiliency and event stream replay.

Moreover, failure in an event hub is rare and duplicate events are less frequent. For more details on building a work flow with no duplicate events refer this stack overflow answer

The details of the checkpoint will be saved in the storage account linked to event hub in the format give below. This can be read using WindowsAzure.Storage client to do custom validation of sequence number of the last event received.

sample checkpoint details

Ranjith Eswaran
  • 333
  • 2
  • 12
  • Thanks for answering. But if I do interval based checkpointing and my time interval is 3 minutes and Event Hubs crashes in between I am re-reading those 2 or so minutes of data, isnt it? In the link that you posted its mentioned "every time the EventProcessorImpl starts - query your downstream for the last sequence no. it got and keep discarding events until the current sequence no." I sense that I need to query from storage but whats the api that I can use to get last sequence number? – tariq zafar Jan 01 '19 at 04:38
  • As far I explored, the checkpoints for each event hub partition are updated within a storage container in json format including details like owner,token,sequence number and offset. So you can directly read the last sequence number from your storage account using WindowsAzure.Storage client in a custom method as the blob will have only the updated(last) sequence number of the event received. – Ranjith Eswaran Jan 02 '19 at 03:39