The name of the consumer group from which you want to process events.
An instance of EventHubClient
that was created for the Event Hub instance.
A user-provided class that extends the PartitionProcessor
class.
This class will be responsible for processing and checkpointing events.
An instance of PartitionManager
. To get started, you can pass an instance of InMemoryPartitionManager
.
For production, choose an implementation that will store checkpoints and partition ownership details to a durable store.
A set of options to configure the Event Processor
maxBatchSize
: The max size of the batch of events passed each time to user code for processing.maxWaitTimeInSeconds
: The maximum amount of time to wait to build up the requested message count before
passing the data to user code for processing. If not provided, it defaults to 60 seconds.The unique identifier for the EventProcessor.
Starts the EventProcessor
. Based on the number of instances of EventProcessor
that are running for the
same consumer group, the partitions are distributed among these instances to process events.
For each partition, the user provided PartitionProcessor
is instantiated.
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.
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.
Generated using TypeDoc
Event Processor based applications consist of one or more instances of EventProcessor which have been configured to consume events from the same Event Hub and consumer group. They balance the workload across different instances by distributing the partitions to be processed among themselves. They also allow the user to track progress when events are processed using checkpoints.
A checkpoint is meant to represent the last successfully processed event by the user from a particular partition of a consumer group in an Event Hub instance.
You need the below to create an instance of
EventProcessor
EventHubClient
class that was created for the Event Hub instance.PartitionProcessor
class. To get started, you can use the base classPartitionProcessor
which simply logs the incoming events. To provide your code to process incoming events, extend this class and override theprocessEvents()
method. For example:class SamplePartitionProcessor extends PartitionProcessor { async processEvents(events) { // user code to process events here // Information on the partition being processed is available as properties on the `SamplePartitionProcessor` class // use `this.updateCheckpoint()` method to update checkpoints as needed } }
PartitionManager
. To get started, you can pass an instance ofInMemoryPartitionManager
. For production, choose an implementation that will store checkpoints and partition ownership details to a durable store. Implementations ofPartitionManager
can be found on npm by searching for packages with the prefix @azure/eventhub-checkpointstore-.EventProcessor