Package com.azure.messaging.eventhubs
Class EventProcessorClient
java.lang.Object
com.azure.messaging.eventhubs.EventProcessorClient
EventProcessorClient provides a convenient mechanism to consume events from all partitions of an Event Hub in the
context of a consumer group. Event Processor-based application consists of one or more instances of
EventProcessorClient(s) which are set up to consume events from the same Event Hub, consumer group to balance the
workload across different instances and track progress when events are processed. Based on the number of instances
running, each EventProcessorClient may own zero or more partitions to balance the workload among all the instances.
To create an instance of EventProcessorClient, use the fluent EventProcessorClientBuilder
.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionThe identifier is a unique name given to this event processor instance.boolean
Returnstrue
if the event processor is running.void
start()
Starts processing of events for all partitions of the Event Hub that this event processor can own, assigning a dedicatedPartitionProcessor
to each partition.void
stop()
Stops processing events for all partitions owned by this event processor.
-
Method Details
-
getIdentifier
The identifier is a unique name given to this event processor instance.- Returns:
- Identifier for this event processor.
-
start
public void start()Starts processing of events for all partitions of the Event Hub that this event processor can own, assigning a dedicatedPartitionProcessor
to each partition. If there are other Event Processors active for the same consumer group on the Event Hub, responsibility for partitions will be shared between them.Subsequent calls to start will be ignored if this event processor is already running. Calling start after
stop()
is called will restart this event processor.Starting the processor to consume events from all partitions
eventProcessorClient.start(); // Continue to perform other tasks while the processor is running in the background. eventProcessorClient.stop();
-
stop
public void stop()Stops processing events for all partitions owned by this event processor. AllPartitionProcessor
will be shutdown and any open resources will be closed.Subsequent calls to stop will be ignored if the event processor is not running.
Stopping the processor
eventProcessorClient.start(); // Continue to perform other tasks while the processor is running in the background. eventProcessorClient.stop();
-
isRunning
public boolean isRunning()Returnstrue
if the event processor is running. If the event processor is already running, callingstart()
has no effect.- Returns:
true
if the event processor is running.
-