title: Azure EventHub: checkpoint best practices in C# EventProcessorClient
body: <p>According to <a href="https://docs.microsoft.com/en-us/dotnet/api/azure.messaging.eventhubs.consumer.eventhubconsumerclient.readeventsasync?view=azure-dotnet" rel="nofollow noreferrer">documentation</a> <code>EventProcessorClient</code> is recommended way to consume eventhub streams:</p>
  
  <blockquote>
    <p><strong>EventProcessorClient</strong> should be used for reading events from all partitions in a production scenario, as it offers a much more robust experience with higher throughput.</p>
  </blockquote>
  
  <p><code>EventProcessorClient</code> allows to update consumer's offset only inside message handler i.e. for each message, something like:</p>
  
  <pre><code>var eventProcessorClient = new EventProcessorClient(...);
  eventProcessorClient.ProcessEventAsync += ProcessEventHandler;
  eventProcessorClient.StartProcessingAsync(stoppingToken);
  
  ...
  
  static async Task ProcessEventHandler(ProcessEventArgs eventArgs)
  {
      Console.WriteLine("Received event: {0}", Encoding.UTF8.GetString(eventArgs.Data.Body.ToArray()));
      await eventArgs.UpdateCheckpointAsync(eventArgs.CancellationToken);
  }
  </code></pre>
  
  <p>At the same time in <a href="https://docs.microsoft.com/en-us/azure/event-hubs/event-processor-balance-partition-load#checkpointing" rel="nofollow noreferrer">documentation for eventhub</a>:</p>
  
  <blockquote>
    <p>Updating after each successfully processed event can have performance and cost implications as it triggers a write operation to the underlying checkpoint store. Also, checkpointing every single event is indicative of a queued messaging pattern for which a Service Bus queue might be a better option than an event hub. The idea behind Event Hubs is that you get "at least once" delivery at great scale.</p>
  </blockquote>
  
  <p>How to update partition checkpoint in efficient way? Should I use kafka client instead of <code>Azure.Messaging.EventHubs</code>?</p>