Class EventProcessorClient

java.lang.Object
com.azure.messaging.eventhubs.EventProcessorClient

public class EventProcessorClient extends Object
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 Type
    Method
    Description
    The identifier is a unique name given to this event processor instance.
    boolean
    Returns true if the event processor is running.
    void
    Starts processing of events for all partitions of the Event Hub that this event processor can own, assigning a dedicated PartitionProcessor to each partition.
    void
    Stops processing events for all partitions owned by this event processor.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getIdentifier

      public String 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 dedicated PartitionProcessor 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. All PartitionProcessor 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()
      Returns true if the event processor is running. If the event processor is already running, calling start() has no effect.
      Returns:
      true if the event processor is running.