Home > Back-end >  Azure Event Hub - EventProcessorClient on specific partition
Azure Event Hub - EventProcessorClient on specific partition

Time:11-28

I am using the EventProcessorClient to read events from an event hub. How can I restrict this client to read from a specific partition?

I create it like this:

EventProcessorClientBuilder eventProcessorClientBuilder = new EventProcessorClientBuilder()
                .connectionString(connectionString, eventHubName)
                .consumerGroup(EventHubClientBuilder.DEFAULT_CONSUMER_GROUP_NAME)
                .processEvent(IncomingEventProcessor.processEvent)
                .processError(processError)
                .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient));

        EventProcessorClient eventProcessorClient = eventProcessorClientBuilder.buildEventProcessorClient();

The function referencer in "processEvent" will be called for all events on the event hub - for all partitions. I can check which partition the event was related to in that function, but I wish to only receive the events that is from a specific partition.

Is this possible using the EventProcessorClient?

CodePudding user response:

It is not possible by using the EventProcessorClient, however you can use the EventHubConsumerAsyncClient class to achieve what you are looking for see doc, It contains a receiveFromPartition method

CodePudding user response:

I found out that EventProcessorClient is selfbalancing - i.e. it will distribute the partitions across the number of instances connected to the event hub.

  • Related