2

I have a running EvenHub which is listened by a windows service. Accidentally, WindowsService stopped working for 2 days. How I can read the data from EventHub where it stopped ? My OffSet setup will look like :

processorOptions.InitialOffsetProvider = (partionId) => DateTime.UtcNow;

I tried to start the windows service again, but its starting from now.

Any idea for this ?

vishnu
  • 223
  • 1
  • 4
  • 16

1 Answers1

3

Do you ever call await context.CheckpointAsync(); in your EventProcessor? If not you will not be able to do this easily. Normally the EventProcessor keeps track what items have been processed. You do that by calling await context.CheckpointAsync(); after some amount of time or after a number of items have been processed by your EventProcessor.

using

processorOptions.InitialOffsetProvider = (partionId) => DateTime.UtcNow;

you basically tell the EventProcessor to ignore all items that have arrived before now. That's not what you need. Remove this call and if you have called await context.CheckpointAsync(); in your processing code it will resume processing items that have not yet been processed. If no checkpoints are available it will start from the beginning of the stream, depending on the configured retention. You will then have to manually skip items you may have already processed.

Some background reading:

understanding check pointing in eventhub

https://blogs.msdn.microsoft.com/servicebus/2015/01/16/event-processor-host-best-practices-part-1/

http://blogs.biztalk360.com/understanding-consumer-side-of-azure-event-hubs-checkpoint-initialoffset-eventprocessorhost/

Community
  • 1
  • 1
Peter Bons
  • 26,826
  • 4
  • 50
  • 74
  • 1
    'await context.CheckpointAsync();' is defined with a specific amount of time. I fixed the issue by the clue provided by you. Set a custom DateTime instead of Utc Date now. Thanks Peter.. :) – vishnu Oct 14 '16 at 07:26