Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions sdk/eventhub/event-hubs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/event-hubs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions sdk/eventhub/event-hubs/review/event-hubs.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface Checkpoint {

// @public
export class CheckpointManager {
// @internal
constructor(partitionContext: PartitionContext, partitionManager: PartitionManager, eventProcessorId: string);
updateCheckpoint(eventData: ReceivedEventData): Promise<void>;
updateCheckpoint(sequenceNumber: number, offset: number): Promise<void>;
Expand Down