Azure event Hub ( Event Processor Host vs Direct Receivers )

376 views Asked by At

I am using Event Hub, wanted to know which one is better approach to consume events Event Processor Host or Direct Receivers. if one of it is better then why.

Also Can you help me any java code sample github or java Azure SDK to write event consumer.

Does using partitions and consumer groups is better approach?

1

There are 1 answers

1
Peter Bons On

Does using partitions and consumer groups is better approach

No matter how you consume events, you alway have at least one consumer group and at least 2 partitions. It is not optional.

Also Can you help me any java code sample github or java Azure SDK to write event consumer.

Plenty of docs available to get started

I am using Event Hub, wanted to know which one is better approach to consume events Event Processor Host or Direct Receivers. if one of it is better then why.

According to the docs:

For most production scenarios, we recommend that you use the event processor client for reading and processing events. The processor client is intended to provide a robust experience for processing events across all partitions of an event hub in a performant and fault tolerant manner while providing a means to checkpoint its progress. Event processor clients can work cooperatively within the context of a consumer group for a given event hub. Clients will automatically manage distribution and balancing of work as instances become available or unavailable for the group.

Regarding direct consumers:

This method is not recommended for production use; the EventProcessorClient should be used for reading events from all partitions in a production scenario, as it offers a much more robust experience with higher throughput.

When using direct consumers you need to manually do the checkpointing. Using the Processor Host takes that away. Also, load distribution is better handled using the Processor Host