diff --git a/sdk/eventhub/event-hubs/README.md b/sdk/eventhub/event-hubs/README.md index b0d7f7388cee..dd29b352fb75 100644 --- a/sdk/eventhub/event-hubs/README.md +++ b/sdk/eventhub/event-hubs/README.md @@ -188,23 +188,29 @@ Using an `EventHubConsumer` to consume events like in the previous examples puts The `EventProcessor` will delegate the processing of events to a `PartitionProcessor` that you provide, allowing you to focus on business logic while the processor holds responsibility for managing the underlying consumer operations including checkpointing and load balancing. -While load balancing is a feature we will be adding in the next update, you can see how to use the `EventProcessor` in the below example, where we use an in memory `PartitionManager` that does checkpointing in memory. +While load balancing is a feature we will be adding in the next update, you can see how to use the `EventProcessor` in the below example, where we use an `InMemoryPartitionManager` that does checkpointing in memory. ```javascript class SimplePartitionProcessor { - async processEvents(events: ReceivedEventData[]) { - // your code here - } - - async processError(error: Error) { - // your error handler here - } + // Gets called once before the processing of events from current partition starts. + async initialize() { /* your code here */ } + + // Gets called for each batch of events that are received. + // You may choose to use the checkpoint manager to update checkpoints. + async processEvents(events) { /* your code here */ } + + // Gets called for any error when receiving events. + async processError(error) { /* your code here */ } + + // Gets called when Event Processor stops processing events for current partition. + async close(reason) { /* your code here */ } } +const client = new EventHubClient("my-connection-string", "my-event-hub"); const processor = new EventProcessor( EventHubClient.defaultConsumerGroupName, client, - () => new SimplePartitionProcessor(), + (partitionContext, checkpointManager) => new SimplePartitionProcessor(), new InMemoryPartitionManager() ); await processor.start(); diff --git a/sdk/eventhub/event-hubs/changelog.md b/sdk/eventhub/event-hubs/changelog.md index d3b8c008ff37..222988a5a696 100644 --- a/sdk/eventhub/event-hubs/changelog.md +++ b/sdk/eventhub/event-hubs/changelog.md @@ -15,7 +15,7 @@ #### Consuming events - Introduced a new class `EventProcessor` which replaces the older concept of [Event Processor Host](https://www.npmjs.com/package/@azure/event-processor-host). - This early preview is intended to allow users to test the new design using a single instance of `EventProcessor`. The ability to checkpoints to a durable store will be added in future updates + - This early preview is intended to allow users to test the new design using a single instance of `EventProcessor`. The ability to store checkpoints to a durable store will be added in future updates #### Retries and timeouts - The properties on the `RetryOptions` interface have been renamed for ease of use. diff --git a/sdk/eventhub/event-hubs/review/event-hubs.api.md b/sdk/eventhub/event-hubs/review/event-hubs.api.md index 93c654c82920..18a159eb9505 100644 --- a/sdk/eventhub/event-hubs/review/event-hubs.api.md +++ b/sdk/eventhub/event-hubs/review/event-hubs.api.md @@ -42,6 +42,7 @@ export interface Checkpoint { // @public export class CheckpointManager { + // @internal constructor(partitionContext: PartitionContext, partitionManager: PartitionManager, eventProcessorId: string); updateCheckpoint(eventData: ReceivedEventData): Promise; updateCheckpoint(sequenceNumber: number, offset: number): Promise;