// Name to be changed
export class EventProcessor {
constructor(
consumerGroupName: string,
eventHubClient: EventHubClient,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This proposal builds on top of what was shipped in Preview 4 of Event Hubs library | |
and attempts to discard a separate notion of EPH by rolling that feature into the | |
existing concept of a "consumer". | |
This is mainly geared towards JS and can be tweaked for Python | |
This needs serious naming re-considerations for the methods on the consumer :) | |
*/ | |
const client = new EventHubClient(connectionString, eventHubName); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Key changes: | |
- A dedicated "client" for EPH, making this a EventHubConsumerClient that customers would first gravitate towards | |
- start() & stop() would be top level methods | |
- In .Net, there would be 4 settable callbacks. These would be in the builder for Java. | |
- For Python & JS, these would be passable to the start() method | |
- State management is done via the PartitionContext that gets passed to the callbacks. | |
- .Net & Java will have to allow users to extend the base class to store the state | |
- This results in a dedicated client for send for symmetry, and so EventHubProducerClient | |
- send() & createBatch() would be top level methods, no need to create producers and maintain them |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// User class extending the base class provided by the library | |
class SamplePartitionProcessor extends PartitionProcessor { | |
async processEvents(events) { console.log(events);} | |
async processError(error) { console.log(error); } | |
async initialize() { console.log(`Started processing partition: ${this.partitionId}`); } | |
async close(reason) { console.log(`Stopped processing partition: ${this.partitionId} for reason ${reason}`); } | |
} | |
// 3 constructor overloads similar to EventHubClient, extra arguments are consumerGroupName, and PartitionProcessor | |
// Options are not shown, but are similar to what EventHubClientOptions support + max batch size, max wait time per batch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
There are 3 players in this game. | |
- EventProcessor | |
- Provided by the sdk. | |
- Ideal Usage: Multiple instances on separate machines to balance partition load | |
- PartitionProcessor | |
- Abstract class provided by the sdk, meant to be extended by user where they provide code to process events | |
- Ideal Usage: | |
- Extended by user & passed to EventProcessor constructor via a factory in .Net & Java, | |
via the type/class name in JS & Python |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Main EventHubClient class | |
export class EventHubClient { | |
// Expects connectionString with EntityPath set to event hub name | |
constructor(connectionString: string, options?: EventHubClientOptions); | |
// Expects user implemented token provider. Token is used for auth over cbs link | |
constructor(host: string, entityPath: string, tokenProvider: TokenProvider, options?: EventHubClientOptions); | |
// Expects user to use @azure/ms-rest-nodeauth library to create the credentials |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"time" | |
servicebus "github.com/Azure/azure-service-bus-go" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Set up instructions: | |
- Ensure you have Nodejs installed, else install from https://nodejs.org/en/ | |
- Copy the this file to an empty folder | |
- Run `npm install @azure/service-bus` in this empty folder | |
- Add your connection string and partitioned queue (no sessions) details in the sample (use empty queue) | |
- Run `node deferred_receiveAndDelete_mode.js` (if you have named the file differently, use that name) | |
- Change the queue to other variations (unparitioned, sessions etc) and see the difference | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Set up instructions: | |
- Ensure you have Go installed, else install from https://golang.org/dl/ | |
- Create a new folder and copy this file | |
- In that folder run `go mod init sbtests` | |
- Add your connection string and queue (no sessions) details | |
- Run `go run deferred_receiveAndDelete_mode.go` (if you have named the file differently, use that name) | |
*/ | |
package main |