@azure/event-hubs 6.0.0-alpha.20250131.1 → 6.0.0-alpha.20250205.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +143 -165
- package/dist/browser/eventHubConsumerClient.d.ts +31 -15
- package/dist/browser/eventHubConsumerClient.d.ts.map +1 -1
- package/dist/browser/eventHubConsumerClient.js.map +1 -1
- package/dist/browser/eventHubProducerClient.d.ts +57 -24
- package/dist/browser/eventHubProducerClient.d.ts.map +1 -1
- package/dist/browser/eventHubProducerClient.js +22 -11
- package/dist/browser/eventHubProducerClient.js.map +1 -1
- package/dist/browser/eventProcessor.d.ts +1 -1
- package/dist/browser/eventProcessor.js.map +1 -1
- package/dist/browser/models/private.d.ts +1 -1
- package/dist/browser/models/private.js.map +1 -1
- package/dist/browser/models/public.d.ts +4 -4
- package/dist/browser/models/public.js.map +1 -1
- package/dist/commonjs/eventHubConsumerClient.d.ts +31 -15
- package/dist/commonjs/eventHubConsumerClient.d.ts.map +1 -1
- package/dist/commonjs/eventHubConsumerClient.js.map +1 -1
- package/dist/commonjs/eventHubProducerClient.d.ts +57 -24
- package/dist/commonjs/eventHubProducerClient.d.ts.map +1 -1
- package/dist/commonjs/eventHubProducerClient.js +22 -11
- package/dist/commonjs/eventHubProducerClient.js.map +1 -1
- package/dist/commonjs/eventProcessor.d.ts +1 -1
- package/dist/commonjs/eventProcessor.js.map +1 -1
- package/dist/commonjs/models/private.d.ts +1 -1
- package/dist/commonjs/models/private.js.map +1 -1
- package/dist/commonjs/models/public.d.ts +4 -4
- package/dist/commonjs/models/public.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/esm/eventHubConsumerClient.d.ts +31 -15
- package/dist/esm/eventHubConsumerClient.d.ts.map +1 -1
- package/dist/esm/eventHubConsumerClient.js.map +1 -1
- package/dist/esm/eventHubProducerClient.d.ts +57 -24
- package/dist/esm/eventHubProducerClient.d.ts.map +1 -1
- package/dist/esm/eventHubProducerClient.js +22 -11
- package/dist/esm/eventHubProducerClient.js.map +1 -1
- package/dist/esm/eventProcessor.d.ts +1 -1
- package/dist/esm/eventProcessor.js.map +1 -1
- package/dist/esm/models/private.d.ts +1 -1
- package/dist/esm/models/private.js.map +1 -1
- package/dist/esm/models/public.d.ts +4 -4
- package/dist/esm/models/public.js.map +1 -1
- package/package.json +12 -13
package/README.md
CHANGED
|
@@ -155,8 +155,8 @@ There are constructor overloads to support different ways of instantiating these
|
|
|
155
155
|
|
|
156
156
|
One of the constructor overloads takes a connection string of the form `Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;` and entity name to your Event Hub instance. You can create a consumer group and get the connection string as well as the entity name from the [Azure portal](https://learn.microsoft.com/azure/event-hubs/event-hubs-get-connection-string#get-connection-string-from-the-portal).
|
|
157
157
|
|
|
158
|
-
```
|
|
159
|
-
|
|
158
|
+
```ts snippet:ReadmeSampleCreateClient_ConnectionString
|
|
159
|
+
import { EventHubProducerClient, EventHubConsumerClient } from "@azure/event-hubs";
|
|
160
160
|
|
|
161
161
|
const producerClient = new EventHubProducerClient("my-connection-string", "my-event-hub");
|
|
162
162
|
const consumerClient = new EventHubConsumerClient(
|
|
@@ -172,8 +172,8 @@ Another constructor overload takes the connection string corresponding to the sh
|
|
|
172
172
|
This connection string will be of the form `Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-event-hub-name`.
|
|
173
173
|
The key difference in the connection string format from the previous constructor overload is the `;EntityPath=my-event-hub-name`.
|
|
174
174
|
|
|
175
|
-
```
|
|
176
|
-
|
|
175
|
+
```ts snippet:ReadmeSampleCreateClient_ConnectionStringWithEntityPath
|
|
176
|
+
import { EventHubProducerClient, EventHubConsumerClient } from "@azure/event-hubs";
|
|
177
177
|
|
|
178
178
|
const producerClient = new EventHubProducerClient("my-connection-string-with-entity-path");
|
|
179
179
|
const consumerClient = new EventHubConsumerClient(
|
|
@@ -186,10 +186,10 @@ const consumerClient = new EventHubConsumerClient(
|
|
|
186
186
|
|
|
187
187
|
This constructor overload takes the host name and entity name of your Event Hub instance and credential that implements the TokenCredential interface. This allows you to authenticate using an Azure Active Directory principal. There are implementations of the `TokenCredential` interface available in the [@azure/identity](https://www.npmjs.com/package/@azure/identity) package. The host name is of the format `<yournamespace>.servicebus.windows.net`. When using Azure Active Directory, your principal must be assigned a role which allows access to Event Hubs, such as the Azure Event Hubs Data Owner role. For more information about using Azure Active Directory authorization with Event Hubs, please refer to [the associated documentation](https://learn.microsoft.com/azure/event-hubs/authorize-access-azure-active-directory).
|
|
188
188
|
|
|
189
|
-
```
|
|
190
|
-
|
|
189
|
+
```ts snippet:ReadmeSampleCreateClient_TokenCredential
|
|
190
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
191
|
+
import { EventHubProducerClient, EventHubConsumerClient } from "@azure/event-hubs";
|
|
191
192
|
|
|
192
|
-
const { DefaultAzureCredential } = require("@azure/identity");
|
|
193
193
|
const credential = new DefaultAzureCredential();
|
|
194
194
|
const producerClient = new EventHubProducerClient("my-host-name", "my-event-hub", credential);
|
|
195
195
|
const consumerClient = new EventHubConsumerClient(
|
|
@@ -260,18 +260,14 @@ To understand what partitions are available, you query the Event Hub using eithe
|
|
|
260
260
|
|
|
261
261
|
In the below example, we are using an `EventHubProducerClient`.
|
|
262
262
|
|
|
263
|
-
```
|
|
264
|
-
|
|
263
|
+
```ts snippet:ReadmeSampleInspectEventHub
|
|
264
|
+
import { EventHubProducerClient } from "@azure/event-hubs";
|
|
265
265
|
|
|
266
|
-
|
|
267
|
-
const client = new EventHubProducerClient("connectionString", "eventHubName");
|
|
266
|
+
const client = new EventHubProducerClient("connectionString", "eventHubName");
|
|
268
267
|
|
|
269
|
-
|
|
268
|
+
const partitionIds = await client.getPartitionIds();
|
|
270
269
|
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
main();
|
|
270
|
+
await client.close();
|
|
275
271
|
```
|
|
276
272
|
|
|
277
273
|
### Publish events to an Event Hub
|
|
@@ -288,28 +284,24 @@ You may publish events to a specific partition, or allow the Event Hubs service
|
|
|
288
284
|
|
|
289
285
|
In the below example, we attempt to send 10 events to Azure Event Hubs.
|
|
290
286
|
|
|
291
|
-
```
|
|
292
|
-
|
|
287
|
+
```ts snippet:ReadmeSamplePublishEvents
|
|
288
|
+
import { EventHubProducerClient } from "@azure/event-hubs";
|
|
293
289
|
|
|
294
|
-
|
|
295
|
-
const producerClient = new EventHubProducerClient("connectionString", "eventHubName");
|
|
290
|
+
const producerClient = new EventHubProducerClient("connectionString", "eventHubName");
|
|
296
291
|
|
|
297
|
-
|
|
298
|
-
|
|
292
|
+
const eventDataBatch = await producerClient.createBatch();
|
|
293
|
+
let numberOfEventsToSend = 10;
|
|
299
294
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
numberOfEventsToSend--;
|
|
295
|
+
while (numberOfEventsToSend > 0) {
|
|
296
|
+
const wasAdded = eventDataBatch.tryAdd({ body: "my-event-body" });
|
|
297
|
+
if (!wasAdded) {
|
|
298
|
+
break;
|
|
306
299
|
}
|
|
307
|
-
|
|
308
|
-
await producerClient.sendBatch(eventDataBatch);
|
|
309
|
-
await producerClient.close();
|
|
300
|
+
numberOfEventsToSend--;
|
|
310
301
|
}
|
|
311
302
|
|
|
312
|
-
|
|
303
|
+
await producerClient.sendBatch(eventDataBatch);
|
|
304
|
+
await producerClient.close();
|
|
313
305
|
```
|
|
314
306
|
|
|
315
307
|
There are options you can pass at different stages to control the process of sending events to Azure Event Hubs.
|
|
@@ -346,43 +338,35 @@ consuming events.
|
|
|
346
338
|
The `subscribe` method takes callbacks to process events as they are received from Azure Event Hubs.
|
|
347
339
|
To stop receiving events, you can call `close()` on the object returned by the `subscribe()` method.
|
|
348
340
|
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
const subscription = client.subscribe(
|
|
366
|
-
{
|
|
367
|
-
processEvents: async (events, context) => {
|
|
368
|
-
// event processing code goes here
|
|
369
|
-
},
|
|
370
|
-
processError: async (err, context) => {
|
|
371
|
-
// error reporting/handling code here
|
|
372
|
-
},
|
|
341
|
+
```ts snippet:ReadmeSampleConsumeEvents
|
|
342
|
+
import { EventHubConsumerClient, earliestEventPosition } from "@azure/event-hubs";
|
|
343
|
+
|
|
344
|
+
const client = new EventHubConsumerClient("my-consumer-group", "connectionString", "eventHubName");
|
|
345
|
+
|
|
346
|
+
// In this sample, we use the position of earliest available event to start from
|
|
347
|
+
// Other common options to configure would be `maxBatchSize` and `maxWaitTimeInSeconds`
|
|
348
|
+
const subscriptionOptions = {
|
|
349
|
+
startPosition: earliestEventPosition,
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
const subscription = client.subscribe(
|
|
353
|
+
{
|
|
354
|
+
processEvents: async (events, context) => {
|
|
355
|
+
// event processing code goes here
|
|
373
356
|
},
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
await client.close();
|
|
381
|
-
console.log(`Exiting sample`);
|
|
382
|
-
}, 3 * 1000);
|
|
383
|
-
}
|
|
357
|
+
processError: async (err, context) => {
|
|
358
|
+
// error reporting/handling code here
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
subscriptionOptions,
|
|
362
|
+
);
|
|
384
363
|
|
|
385
|
-
|
|
364
|
+
// Wait for a few seconds to receive events before closing
|
|
365
|
+
setTimeout(async () => {
|
|
366
|
+
await subscription.close();
|
|
367
|
+
await client.close();
|
|
368
|
+
console.log(`Exiting sample`);
|
|
369
|
+
}, 3 * 1000);
|
|
386
370
|
```
|
|
387
371
|
|
|
388
372
|
#### Consume events with load balanced across multiple processes
|
|
@@ -402,10 +386,10 @@ which implements the required read/writes to a durable store by using Azure Blob
|
|
|
402
386
|
The `subscribe` method takes callbacks to process events as they are received from Azure Event Hubs.
|
|
403
387
|
To stop receiving events, you can call `close()` on the object returned by the `subscribe()` method.
|
|
404
388
|
|
|
405
|
-
```
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
389
|
+
```ts snippet:ReadmeSampleConsumeEventsLoadBalancing
|
|
390
|
+
import { ContainerClient } from "@azure/storage-blob";
|
|
391
|
+
import { BlobCheckpointStore } from "@azure/eventhubs-checkpointstore-blob";
|
|
392
|
+
import { EventHubConsumerClient } from "@azure/event-hubs";
|
|
409
393
|
|
|
410
394
|
const storageAccountConnectionString = "storage-account-connection-string";
|
|
411
395
|
const containerName = "container-name";
|
|
@@ -413,53 +397,49 @@ const eventHubConnectionString = "eventhub-connection-string";
|
|
|
413
397
|
const consumerGroup = "my-consumer-group";
|
|
414
398
|
const eventHubName = "eventHubName";
|
|
415
399
|
|
|
416
|
-
|
|
417
|
-
const blobContainerClient = new ContainerClient(storageAccountConnectionString, containerName);
|
|
418
|
-
|
|
419
|
-
if (!(await blobContainerClient.exists())) {
|
|
420
|
-
await blobContainerClient.create();
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
const checkpointStore = new BlobCheckpointStore(blobContainerClient);
|
|
424
|
-
const consumerClient = new EventHubConsumerClient(
|
|
425
|
-
consumerGroup,
|
|
426
|
-
eventHubConnectionString,
|
|
427
|
-
eventHubName,
|
|
428
|
-
checkpointStore,
|
|
429
|
-
);
|
|
400
|
+
const blobContainerClient = new ContainerClient(storageAccountConnectionString, containerName);
|
|
430
401
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
if (events.length === 0) {
|
|
435
|
-
// If the wait time expires (configured via options in maxWaitTimeInSeconds) Event Hubs
|
|
436
|
-
// will pass you an empty array.
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
// Checkpointing will allow your service to pick up from
|
|
441
|
-
// where it left off when restarting.
|
|
442
|
-
//
|
|
443
|
-
// You'll want to balance how often you checkpoint with the
|
|
444
|
-
// performance of your underlying checkpoint store.
|
|
445
|
-
await context.updateCheckpoint(events[events.length - 1]);
|
|
446
|
-
},
|
|
447
|
-
processError: async (err, context) => {
|
|
448
|
-
// handle any errors that occur during the course of
|
|
449
|
-
// this subscription
|
|
450
|
-
console.log(`Errors in subscription to partition ${context.partitionId}: ${err}`);
|
|
451
|
-
},
|
|
452
|
-
});
|
|
402
|
+
if (!(await blobContainerClient.exists())) {
|
|
403
|
+
await blobContainerClient.create();
|
|
404
|
+
}
|
|
453
405
|
|
|
454
|
-
|
|
455
|
-
|
|
406
|
+
const checkpointStore = new BlobCheckpointStore(blobContainerClient);
|
|
407
|
+
const consumerClient = new EventHubConsumerClient(
|
|
408
|
+
consumerGroup,
|
|
409
|
+
eventHubConnectionString,
|
|
410
|
+
eventHubName,
|
|
411
|
+
checkpointStore,
|
|
412
|
+
);
|
|
456
413
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
414
|
+
const subscription = consumerClient.subscribe({
|
|
415
|
+
processEvents: async (events, context) => {
|
|
416
|
+
// event processing code goes here
|
|
417
|
+
if (events.length === 0) {
|
|
418
|
+
// If the wait time expires (configured via options in maxWaitTimeInSeconds) Event Hubs
|
|
419
|
+
// will pass you an empty array.
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
461
422
|
|
|
462
|
-
|
|
423
|
+
// Checkpointing will allow your service to pick up from
|
|
424
|
+
// where it left off when restarting.
|
|
425
|
+
//
|
|
426
|
+
// You'll want to balance how often you checkpoint with the
|
|
427
|
+
// performance of your underlying checkpoint store.
|
|
428
|
+
await context.updateCheckpoint(events[events.length - 1]);
|
|
429
|
+
},
|
|
430
|
+
processError: async (err, context) => {
|
|
431
|
+
// handle any errors that occur during the course of
|
|
432
|
+
// this subscription
|
|
433
|
+
console.log(`Errors in subscription to partition ${context.partitionId}: ${err}`);
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
// Wait for a few seconds to receive events before closing
|
|
438
|
+
await new Promise((resolve) => setTimeout(resolve, 10 * 1000));
|
|
439
|
+
|
|
440
|
+
await subscription.close();
|
|
441
|
+
await consumerClient.close();
|
|
442
|
+
console.log(`Exiting sample`);
|
|
463
443
|
```
|
|
464
444
|
|
|
465
445
|
Please see [Balance partition load across multiple instances of your application](https://learn.microsoft.com/azure/event-hubs/event-processor-balance-partition-load)
|
|
@@ -475,45 +455,37 @@ In the below example, we are using the first partition.
|
|
|
475
455
|
The `subscribe` method takes callbacks to process events as they are received from Azure Event Hubs.
|
|
476
456
|
To stop receiving events, you can call `close()` on the object returned by the `subscribe()` method.
|
|
477
457
|
|
|
478
|
-
```
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
const subscription = client.subscribe(
|
|
496
|
-
partitionIds[0],
|
|
497
|
-
{
|
|
498
|
-
processEvents: async (events, context) => {
|
|
499
|
-
// event processing code goes here
|
|
500
|
-
},
|
|
501
|
-
processError: async (err, context) => {
|
|
502
|
-
// error reporting/handling code here
|
|
503
|
-
},
|
|
458
|
+
```ts snippet:ReadmeSampleConsumeEventsFromPartition
|
|
459
|
+
import { EventHubConsumerClient, earliestEventPosition } from "@azure/event-hubs";
|
|
460
|
+
|
|
461
|
+
const client = new EventHubConsumerClient("my-consumer-group", "connectionString", "eventHubName");
|
|
462
|
+
const partitionIds = await client.getPartitionIds();
|
|
463
|
+
|
|
464
|
+
// In this sample, we use the position of earliest available event to start from
|
|
465
|
+
// Other common options to configure would be `maxBatchSize` and `maxWaitTimeInSeconds`
|
|
466
|
+
const subscriptionOptions = {
|
|
467
|
+
startPosition: earliestEventPosition,
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
const subscription = client.subscribe(
|
|
471
|
+
partitionIds[0],
|
|
472
|
+
{
|
|
473
|
+
processEvents: async (events, context) => {
|
|
474
|
+
// event processing code goes here
|
|
504
475
|
},
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
await client.close();
|
|
512
|
-
console.log(`Exiting sample`);
|
|
513
|
-
}, 3 * 1000);
|
|
514
|
-
}
|
|
476
|
+
processError: async (err, context) => {
|
|
477
|
+
// error reporting/handling code here
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
subscriptionOptions,
|
|
481
|
+
);
|
|
515
482
|
|
|
516
|
-
|
|
483
|
+
// Wait for a few seconds to receive events before closing
|
|
484
|
+
setTimeout(async () => {
|
|
485
|
+
await subscription.close();
|
|
486
|
+
await client.close();
|
|
487
|
+
console.log(`Exiting sample`);
|
|
488
|
+
}, 3 * 1000);
|
|
517
489
|
```
|
|
518
490
|
|
|
519
491
|
### Use EventHubConsumerClient to work with IotHub
|
|
@@ -526,23 +498,21 @@ hence sending events is not possible.
|
|
|
526
498
|
[Event Hub-compatible endpoint](https://learn.microsoft.com/azure/iot-hub/iot-hub-devguide-messages-read-builtin)
|
|
527
499
|
(e.g. "Endpoint=sb://my-iothub-namespace-[uid].servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-iot-hub-name")
|
|
528
500
|
|
|
529
|
-
```
|
|
530
|
-
|
|
501
|
+
```ts snippet:ReadmeSampleConsumeEventsFromIotHub
|
|
502
|
+
import { EventHubConsumerClient } from "@azure/event-hubs";
|
|
531
503
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
);
|
|
537
|
-
await client.getEventHubProperties();
|
|
538
|
-
// retrieve partitionIds from client.getEventHubProperties() or client.getPartitionIds()
|
|
539
|
-
const partitionId = "0";
|
|
540
|
-
await client.getPartitionProperties(partitionId);
|
|
504
|
+
const client = new EventHubConsumerClient(
|
|
505
|
+
"my-consumer-group",
|
|
506
|
+
"Endpoint=sb://my-iothub-namespace-[uid].servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-iot-hub-name",
|
|
507
|
+
);
|
|
541
508
|
|
|
542
|
-
|
|
543
|
-
|
|
509
|
+
await client.getEventHubProperties();
|
|
510
|
+
|
|
511
|
+
// retrieve partitionIds from client.getEventHubProperties() or client.getPartitionIds()
|
|
512
|
+
const partitionId = "0";
|
|
513
|
+
await client.getPartitionProperties(partitionId);
|
|
544
514
|
|
|
545
|
-
|
|
515
|
+
await client.close();
|
|
546
516
|
```
|
|
547
517
|
|
|
548
518
|
## Troubleshooting
|
|
@@ -559,6 +529,14 @@ You can set the `AZURE_LOG_LEVEL` environment variable to enable logging to `std
|
|
|
559
529
|
export AZURE_LOG_LEVEL=verbose
|
|
560
530
|
```
|
|
561
531
|
|
|
532
|
+
Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
|
|
533
|
+
|
|
534
|
+
```ts snippet:SetLogLevel
|
|
535
|
+
import { setLogLevel } from "@azure/logger";
|
|
536
|
+
|
|
537
|
+
setLogLevel("info");
|
|
538
|
+
```
|
|
539
|
+
|
|
562
540
|
For more detailed instructions on how to enable logs, you can look at the
|
|
563
541
|
[@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
|
|
564
542
|
|
|
@@ -215,14 +215,21 @@ export declare class EventHubConsumerClient {
|
|
|
215
215
|
* Call close() on the returned object to stop receiving events.
|
|
216
216
|
*
|
|
217
217
|
* Example usage:
|
|
218
|
-
* ```ts
|
|
219
|
-
*
|
|
218
|
+
* ```ts snippet:EventHubConsumerClient_Subscribe
|
|
219
|
+
* import { EventHubConsumerClient, earliestEventPosition } from "@azure/event-hubs";
|
|
220
|
+
*
|
|
221
|
+
* const client = new EventHubConsumerClient("my-consumer-group", "connectionString", "eventHubName");
|
|
222
|
+
*
|
|
220
223
|
* const subscription = client.subscribe(
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
224
|
+
* {
|
|
225
|
+
* processEvents: async (events, context) => {
|
|
226
|
+
* console.log("Received event count: ", events.length);
|
|
227
|
+
* },
|
|
228
|
+
* processError: async (err, context) => {
|
|
229
|
+
* console.log("Error: ", err);
|
|
230
|
+
* },
|
|
231
|
+
* },
|
|
232
|
+
* { startPosition: earliestEventPosition },
|
|
226
233
|
* );
|
|
227
234
|
* ```
|
|
228
235
|
*
|
|
@@ -240,15 +247,24 @@ export declare class EventHubConsumerClient {
|
|
|
240
247
|
* Call close() on the returned object to stop receiving events.
|
|
241
248
|
*
|
|
242
249
|
* Example usage:
|
|
243
|
-
* ```ts
|
|
244
|
-
*
|
|
250
|
+
* ```ts snippet:EventHubConsumerClient_SubscribeSinglePartition
|
|
251
|
+
* import { EventHubConsumerClient, earliestEventPosition } from "@azure/event-hubs";
|
|
252
|
+
*
|
|
253
|
+
* const client = new EventHubConsumerClient("my-consumer-group", "connectionString", "eventHubName");
|
|
254
|
+
*
|
|
255
|
+
* const partitionIds = await client.getPartitionIds();
|
|
256
|
+
*
|
|
245
257
|
* const subscription = client.subscribe(
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
258
|
+
* partitionIds[0],
|
|
259
|
+
* {
|
|
260
|
+
* processEvents: async (events, context) => {
|
|
261
|
+
* console.log("Received event count: ", events.length);
|
|
262
|
+
* },
|
|
263
|
+
* processError: async (err, context) => {
|
|
264
|
+
* console.log("Error: ", err);
|
|
265
|
+
* },
|
|
266
|
+
* },
|
|
267
|
+
* { startPosition: earliestEventPosition },
|
|
252
268
|
* );
|
|
253
269
|
* ```
|
|
254
270
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventHubConsumerClient.d.ts","sourceRoot":"","sources":["../../src/eventHubConsumerClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAA6B,MAAM,qBAAqB,CAAC;AAItF,OAAO,KAAK,EACV,6BAA6B,EAC7B,4BAA4B,EAC5B,sBAAsB,EACtB,6BAA6B,EAE9B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,yBAAyB,EAC1B,MAAM,mCAAmC,CAAC;AAsB3C;;;;;;;;;;;;;;GAcG;AACH,qBAAa,sBAAsB;IAuM/B,OAAO,CAAC,cAAc;IAtMxB;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAoB;IACpC;;OAEG;IACH,OAAO,CAAC,cAAc,CAAgC;IACtD,OAAO,CAAC,cAAc,CAAuB;IAE7C;;;;OAIG;IACH,OAAO,CAAC,cAAc,CAA2B;IAEjD;;OAEG;IACH,MAAM,CAAC,wBAAwB,EAAE,MAAM,CAAkC;IAEzE,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,yBAAyB,CAAU;IAE3C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAiC;IAEvE;;;OAGG;IACH,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED;;;;OAIG;IACH,IAAI,uBAAuB,IAAI,MAAM,CAEpC;IAED;;;OAGG;IACH,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC;;;;;;;;;;;;OAYG;gBAED,aAAa,EAAE,MA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