@azure/event-hubs 5.13.0-alpha.20250107.2 → 5.13.0-alpha.20250114.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 CHANGED
@@ -1,13 +1,14 @@
1
1
  # Azure Event Hubs client library for JavaScript
2
2
 
3
- Azure Event Hubs is a highly scalable publish-subscribe service that can ingest millions of events per second and stream them to multiple consumers. This lets you process and analyze the massive amounts of data produced by your connected devices and applications. If you would like to know more about Azure Event Hubs, you may wish to review: [What is Event Hubs](https://docs.microsoft.com/azure/event-hubs/event-hubs-about)?
3
+ Azure Event Hubs is a highly scalable publish-subscribe service that can ingest millions of events per second and stream them to multiple consumers. This lets you process and analyze the massive amounts of data produced by your connected devices and applications. If you would like to know more about Azure Event Hubs, you may wish to review: [What is Event Hubs](https://learn.microsoft.com/azure/event-hubs/event-hubs-about)?
4
4
 
5
5
  The Azure Event Hubs client library allows you to send and receive events in your Node.js application.
6
6
 
7
7
  Key links:
8
+
8
9
  - [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/eventhub/event-hubs)
9
10
  - [Package (npm)](https://www.npmjs.com/package/@azure/event-hubs)
10
- - [API Reference Documentation](https://docs.microsoft.com/javascript/api/@azure/event-hubs)
11
+ - [API Reference Documentation](https://learn.microsoft.com/javascript/api/@azure/event-hubs)
11
12
  - [Product documentation](https://azure.microsoft.com/services/event-hubs/)
12
13
  - [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/eventhub/event-hubs/samples)
13
14
 
@@ -38,7 +39,7 @@ See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUP
38
39
  ### Prerequisites
39
40
 
40
41
  - An [Azure subscription](https://azure.microsoft.com/free/)
41
- - An [Event Hubs Namespace](https://docs.microsoft.com/azure/event-hubs/)
42
+ - An [Event Hubs Namespace](https://learn.microsoft.com/azure/event-hubs/)
42
43
 
43
44
  #### Configure TypeScript
44
45
 
@@ -141,18 +142,18 @@ Please consult the documentation of your favorite bundler for more information o
141
142
 
142
143
  ### React Native Support
143
144
 
144
- Similar to browsers, React Native does not support some JavaScript API used by this SDK library so you need to provide polyfills for them. Please see the [Messaging React Native sample with Expo](https://github.com/Azure/azure-sdk-for-js/blob/main/samples/frameworks/react-native-expo/ts/messaging/README.md) for more details.
145
+ Similar to browsers, React Native does not support some JavaScript API used by this SDK library so you need to provide polyfills for them. Please see the [Messaging React Native sample with Expo](https://github.com/Azure/azure-sdk-for-js/blob/main/samples/frameworks/react-native-expo/ts/messaging/README.md) for more details.
145
146
 
146
147
  ### Authenticate the client
147
148
 
148
149
  Interaction with Event Hubs starts with either an instance of the
149
- [EventHubConsumerClient](https://docs.microsoft.com/javascript/api/@azure/event-hubs/eventhubconsumerclient) class
150
- or an instance of the [EventHubProducerClient](https://docs.microsoft.com/javascript/api/@azure/event-hubs/eventhubproducerclient) class.
150
+ [EventHubConsumerClient](https://learn.microsoft.com/javascript/api/@azure/event-hubs/eventhubconsumerclient) class
151
+ or an instance of the [EventHubProducerClient](https://learn.microsoft.com/javascript/api/@azure/event-hubs/eventhubproducerclient) class.
151
152
  There are constructor overloads to support different ways of instantiating these classes as shown below:
152
153
 
153
154
  #### Use connection string for the Event Hubs namespace
154
155
 
155
- 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://docs.microsoft.com/azure/event-hubs/event-hubs-get-connection-string#get-connection-string-from-the-portal).
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).
156
157
 
157
158
  ```javascript
158
159
  const { EventHubProducerClient, EventHubConsumerClient } = require("@azure/event-hubs");
@@ -161,7 +162,7 @@ const producerClient = new EventHubProducerClient("my-connection-string", "my-ev
161
162
  const consumerClient = new EventHubConsumerClient(
162
163
  "my-consumer-group",
163
164
  "my-connection-string",
164
- "my-event-hub"
165
+ "my-event-hub",
165
166
  );
166
167
  ```
167
168
 
@@ -177,13 +178,13 @@ const { EventHubProducerClient, EventHubConsumerClient } = require("@azure/event
177
178
  const producerClient = new EventHubProducerClient("my-connection-string-with-entity-path");
178
179
  const consumerClient = new EventHubConsumerClient(
179
180
  "my-consumer-group",
180
- "my-connection-string-with-entity-path"
181
+ "my-connection-string-with-entity-path",
181
182
  );
182
183
  ```
183
184
 
184
185
  #### Use the Event Hubs namespace and Azure Identity
185
186
 
186
- 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://docs.microsoft.com/azure/event-hubs/authorize-access-azure-active-directory).
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).
187
188
 
188
189
  ```javascript
189
190
  const { EventHubProducerClient, EventHubConsumerClient } = require("@azure/event-hubs");
@@ -195,7 +196,7 @@ const consumerClient = new EventHubConsumerClient(
195
196
  "my-consumer-group",
196
197
  "my-host-name",
197
198
  "my-event-hub",
198
- credential
199
+ credential,
199
200
  );
200
201
  ```
201
202
 
@@ -209,7 +210,7 @@ const consumerClient = new EventHubConsumerClient(
209
210
 
210
211
  - A **consumer group** is a view of an entire Event Hub. Consumer groups enable multiple consuming applications to each have a separate view of the event stream, and to read the stream independently at their own pace and from their own position. There can be at most 5 concurrent readers on a partition per consumer group; however it is recommended that there is only one active consumer for a given partition and consumer group pairing. Each active reader receives all of the events from its partition; If there are multiple readers on the same partition, then they will receive duplicate events.
211
212
 
212
- For more concepts and deeper discussion, see: [Event Hubs Features](https://docs.microsoft.com/azure/event-hubs/event-hubs-features)
213
+ For more concepts and deeper discussion, see: [Event Hubs Features](https://learn.microsoft.com/azure/event-hubs/event-hubs-features)
213
214
 
214
215
  ### Guidance around retries
215
216
 
@@ -280,10 +281,10 @@ In order to publish events, you'll need to create an `EventHubProducerClient`. W
280
281
 
281
282
  You may publish events to a specific partition, or allow the Event Hubs service to decide which partition events should be published to. It is recommended to use automatic routing when the publishing of events needs to be highly available or when event data should be distributed evenly among the partitions. In the example below, we will take advantage of automatic routing.
282
283
 
283
- - Create an `EventDataBatch` object using the [createBatch](https://docs.microsoft.com/javascript/api/@azure/event-hubs/eventhubproducerclient#createbatch-createbatchoptions-)
284
- - Add events to the batch using the [tryAdd](https://docs.microsoft.com/javascript/api/@azure/event-hubs/eventdatabatch#tryadd-eventdata--tryaddoptions-)
284
+ - Create an `EventDataBatch` object using the [createBatch](https://learn.microsoft.com/javascript/api/@azure/event-hubs/eventhubproducerclient#createbatch-createbatchoptions-)
285
+ - Add events to the batch using the [tryAdd](https://learn.microsoft.com/javascript/api/@azure/event-hubs/eventdatabatch#tryadd-eventdata--tryaddoptions-)
285
286
  method. You can do this until the maximum batch size limit is reached or until you are done adding the number of events you liked, whichever comes first. This method would return `false` to indicate that no more events can be added to the batch due to the max batch size being reached.
286
- - Send the batch of events using the [sendBatch](https://docs.microsoft.com/javascript/api/@azure/event-hubs/eventhubproducerclient#sendbatch-eventdatabatch--sendbatchoptions-) method.
287
+ - Send the batch of events using the [sendBatch](https://learn.microsoft.com/javascript/api/@azure/event-hubs/eventhubproducerclient#sendbatch-eventdatabatch--sendbatchoptions-) method.
287
288
 
288
289
  In the below example, we attempt to send 10 events to Azure Event Hubs.
289
290
 
@@ -325,7 +326,7 @@ For example: `body: { "message": "Hello World" }`
325
326
  ### Consume events from an Event Hub
326
327
 
327
328
  To consume events from an Event Hub instance, you also need to know which consumer group you want to target.
328
- Once you know this, you are ready to create an [EventHubConsumerClient](https://docs.microsoft.com/javascript/api/@azure/event-hubs/eventhubconsumerclient). While the below example shows one way to create the client, see the
329
+ Once you know this, you are ready to create an [EventHubConsumerClient](https://learn.microsoft.com/javascript/api/@azure/event-hubs/eventhubconsumerclient). While the below example shows one way to create the client, see the
329
330
  [Authenticate the client](#authenticate-the-client) section to learn other ways to instantiate the client.
330
331
 
331
332
  The `subscribe` method on the client has overloads which, combined with the constructor, can cater to several
@@ -352,13 +353,13 @@ async function main() {
352
353
  const client = new EventHubConsumerClient(
353
354
  "my-consumer-group",
354
355
  "connectionString",
355
- "eventHubName"
356
+ "eventHubName",
356
357
  );
357
358
 
358
359
  // In this sample, we use the position of earliest available event to start from
359
360
  // Other common options to configure would be `maxBatchSize` and `maxWaitTimeInSeconds`
360
361
  const subscriptionOptions = {
361
- startPosition: earliestEventPosition
362
+ startPosition: earliestEventPosition,
362
363
  };
363
364
 
364
365
  const subscription = client.subscribe(
@@ -368,9 +369,9 @@ async function main() {
368
369
  },
369
370
  processError: async (err, context) => {
370
371
  // error reporting/handling code here
371
- }
372
+ },
372
373
  },
373
- subscriptionOptions
374
+ subscriptionOptions,
374
375
  );
375
376
 
376
377
  // Wait for a few seconds to receive events before closing
@@ -424,7 +425,7 @@ async function main() {
424
425
  consumerGroup,
425
426
  eventHubConnectionString,
426
427
  eventHubName,
427
- checkpointStore
428
+ checkpointStore,
428
429
  );
429
430
 
430
431
  const subscription = consumerClient.subscribe({
@@ -447,7 +448,7 @@ async function main() {
447
448
  // handle any errors that occur during the course of
448
449
  // this subscription
449
450
  console.log(`Errors in subscription to partition ${context.partitionId}: ${err}`);
450
- }
451
+ },
451
452
  });
452
453
 
453
454
  // Wait for a few seconds to receive events before closing
@@ -461,7 +462,7 @@ async function main() {
461
462
  main();
462
463
  ```
463
464
 
464
- Please see [Balance partition load across multiple instances of your application](https://docs.microsoft.com/azure/event-hubs/event-processor-balance-partition-load)
465
+ Please see [Balance partition load across multiple instances of your application](https://learn.microsoft.com/azure/event-hubs/event-processor-balance-partition-load)
465
466
  to learn more.
466
467
 
467
468
  #### Consume events from a single partition
@@ -481,14 +482,14 @@ async function main() {
481
482
  const client = new EventHubConsumerClient(
482
483
  "my-consumer-group",
483
484
  "connectionString",
484
- "eventHubName"
485
+ "eventHubName",
485
486
  );
486
487
  const partitionIds = await client.getPartitionIds();
487
488
 
488
489
  // In this sample, we use the position of earliest available event to start from
489
490
  // Other common options to configure would be `maxBatchSize` and `maxWaitTimeInSeconds`
490
491
  const subscriptionOptions = {
491
- startPosition: earliestEventPosition
492
+ startPosition: earliestEventPosition,
492
493
  };
493
494
 
494
495
  const subscription = client.subscribe(
@@ -499,9 +500,9 @@ async function main() {
499
500
  },
500
501
  processError: async (err, context) => {
501
502
  // error reporting/handling code here
502
- }
503
+ },
503
504
  },
504
- subscriptionOptions
505
+ subscriptionOptions,
505
506
  );
506
507
 
507
508
  // Wait for a few seconds to receive events before closing
@@ -522,7 +523,7 @@ The associated connection string will not have send claims,
522
523
  hence sending events is not possible.
523
524
 
524
525
  - Please notice that the connection string needs to be for an
525
- [Event Hub-compatible endpoint](https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messages-read-builtin)
526
+ [Event Hub-compatible endpoint](https://learn.microsoft.com/azure/iot-hub/iot-hub-devguide-messages-read-builtin)
526
527
  (e.g. "Endpoint=sb://my-iothub-namespace-[uid].servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-iot-hub-name")
527
528
 
528
529
  ```javascript
@@ -531,7 +532,7 @@ const { EventHubConsumerClient } = require("@azure/event-hubs");
531
532
  async function main() {
532
533
  const client = new EventHubConsumerClient(
533
534
  "my-consumer-group",
534
- "Endpoint=sb://my-iothub-namespace-[uid].servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-iot-hub-name"
535
+ "Endpoint=sb://my-iothub-namespace-[uid].servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-iot-hub-name",
535
536
  );
536
537
  await client.getEventHubProperties();
537
538
  // retrieve partitionIds from client.getEventHubProperties() or client.getPartitionIds()
@@ -598,7 +599,7 @@ export DEBUG=azure:*:(error|warning),rhea-promise:error,rhea:events,rhea:frames,
598
599
 
599
600
  Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/eventhub/event-hubs/samples)
600
601
  directory for detailed examples of how to use this library to send and receive events to/from
601
- [Event Hubs](https://docs.microsoft.com/azure/event-hubs/event-hubs-about).
602
+ [Event Hubs](https://learn.microsoft.com/azure/event-hubs/event-hubs-about).
602
603
 
603
604
  ## Contributing
604
605
 
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.48.1"
8
+ "packageVersion": "7.49.1"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@azure/event-hubs",
3
3
  "sdk-type": "client",
4
- "version": "5.13.0-alpha.20250107.2",
4
+ "version": "5.13.0-alpha.20250114.1",
5
5
  "description": "Azure Event Hubs SDK for JS.",
6
6
  "author": "Microsoft Corporation",
7
7
  "license": "MIT",
@@ -83,7 +83,7 @@
83
83
  "azure-event-hubs"
84
84
  ],
85
85
  "requiredResources": {
86
- "Azure Event Hub": "https://docs.microsoft.com/azure/event-hubs/event-hubs-create"
86
+ "Azure Event Hub": "https://learn.microsoft.com/azure/event-hubs/event-hubs-create"
87
87
  }
88
88
  },
89
89
  "tshy": {