When does Azure's EventProcessorHost call IEventProcessor.ProcessEventsAsync?

1.6k views Asked by At

I'm writing a worker for Azure EventHub and I expect to be building on top of EventProcessorHost; however, I couldn't find some potentially relevant details either in the general documentation or the API documentation.

When is IEventProcessor ProcessEventsAsync called by the EventProcessorHost?

This method is called when there are new messages in the Event Hubs stream. Make sure to checkpoint only when you are finished processing all the events in each batch.

While we know that there will be some results in the messages enumerable, the documentation is silent on whether or not we can expect concurrent calls to ProcessEventsAsync or a second call while the first is in progress. Given the instructions on when to checkpoint neither would make much sense as the second call could complete and checkpoint further along in the stream than is processed since the first doesn't complete, but confirmation in the documentation would be great.

I assume that the output of each call to CreateEventProcessor (or IEventProcessor if they are unique) is used by the EventProcessorHost for one partition, and that the PartitionContext

Similarly is whether a call to CheckpointAsync has any effect on ProcessEventsAsync being called. While it shouldn't to allow later checkpointing, I could see it being a rational choice. I have some other questions about the mechanics of check pointing which I will address in another question (link will go here).

Will any more ProcessEventsAsync calls be made after a CloseAsync call has been made (I would assume not, but didn't find it)? Will it be made with a Task returned from ProcessEventsAsync uncompleted?

In short the answer that makes sense to me is that ProcessEventsAsync will not be called, for a given processor until the Task from the prior call has completed, but I cannot confirm this from the documentation.

1

There are 1 answers

3
Pragmatic On

Although following information is not validated but logically it should be working like this -

  1. There should not be any concurrent call to ProcessEventAsync inside one partition. Otherwise how would azure give guarantee on ordering of messages inside one partition.
  2. We might have to process each message asynchronously. Otherwise system cannot handle more than 32 message concurrently. (assuming there are 32 partitions).