Skip to content

Commit 7e9fcae

Browse files
authored
Update Service Bus migration guide with more pointers, and use similar general text in Event Hubs (Azure#12350)
1 parent ae679b5 commit 7e9fcae

File tree

2 files changed

+90
-22
lines changed

2 files changed

+90
-22
lines changed

sdk/eventhub/event-hubs/migrationguide.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ to migrate their application to V5 of the same library.
55

66
For users new to the JavaScript SDK for Event Hubs, please see the [readme file for the @azure/event-hubs package](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/eventhub/event-hubs/README.md).
77

8+
## Migration benefits
9+
10+
A natural question to ask when considering whether or not to adopt a new version or library is what the benefits of doing so would be. As Azure has matured and been embraced by a more diverse group of developers, we have been focused on learning the patterns and practices to best support developer productivity and to understand the gaps that the JavaScript client libraries have.
11+
12+
There were several areas of consistent feedback expressed across the Azure client library ecosystem. One of the most important is that the client libraries for different Azure services have not had a consistent approach to organization, naming, and API structure. Additionally, many developers have felt that the learning curve was difficult, and the APIs did not offer a good, approachable, and consistent onboarding story for those learning Azure or exploring a specific Azure service.
13+
14+
To try and improve the development experience across Azure services, including Event Hubs, a set of uniform [design guidelines](https://azure.github.io/azure-sdk/general_introduction.html) was created for all languages to drive a consistent experience with established API patterns for all services. A set of [TypeScript & JavaScript specific guidelines](https://azure.github.io/azure-sdk/typescript_introduction.html) was also introduced to ensure that these libraries have a natural and idiomatic feel. Further details are available in the guidelines for those interested.
15+
16+
The new version 5 of the Event Hubs library provides the ability to share in some of the cross-service improvements made to the Azure development experience, such as using the new `@azure/identity` library to share a single authentication between clients and a unified diagnostics pipeline offering a common view of the activities across each of the client libraries.
17+
818
## General changes
919

1020
Version 5 of the `@azure/event-hubs` package is a result of our efforts to

sdk/servicebus/service-bus/migrationguide.md

Lines changed: 80 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,84 @@
11
# Guide to migrate from @azure/service-bus v1 to v7
22

3-
This document is intended for users that would like to try out preview 8
4-
for @azure/service-bus. As the package is in preview, these details might
5-
change as the package is developed before its final release.
3+
This guide is intended to assist in the migration from version 1 of the Service Bus client library `@azure/service-bus` to version 7 of the same library. It will focus on side-by-side comparisons for similar operations between the two packages.
64

7-
## General changes
5+
Familiarity with the version 1 of the `@azure/service-bus` library is assumed. For those new to the Service Bus client library for JavaScript, please refer to the [README](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/servicebus/service-bus/README.md) and [Service Bus samples](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/servicebus/service-bus/samples) for the `@azure/service-bus` library rather than this guide.
86

9-
Version 7 of `@azure/service-bus` provides some "under-the-hood" changes
10-
by standardizing on common infrastructure with `@azure/event-hubs`. This change
11-
brings this package in line with the [Azure SDK Design Guidelines for Typescript](https://azure.github.io/azure-sdk/typescript_introduction.html#design-principles).
7+
## Migration benefits
128

13-
## API changes from V1 to V7
9+
A natural question to ask when considering whether or not to adopt a new version or library is what the benefits of doing so would be. As Azure has matured and been embraced by a more diverse group of developers, we have been focused on learning the patterns and practices to best support developer productivity and to understand the gaps that the JavaScript client libraries have.
1410

15-
### Creating ServiceBusClient
11+
There were several areas of consistent feedback expressed across the Azure client library ecosystem. One of the most important is that the client libraries for different Azure services have not had a consistent approach to organization, naming, and API structure. Additionally, many developers have felt that the learning curve was difficult, and the APIs did not offer a good, approachable, and consistent onboarding story for those learning Azure or exploring a specific Azure service.
1612

17-
- `ServiceBusClient` can now be constructed using new(). The static methods to
18-
construct it have been removed.
13+
To try and improve the development experience across Azure services, including Service Bus, a set of uniform [design guidelines](https://azure.github.io/azure-sdk/general_introduction.html) was created for all languages to drive a consistent experience with established API patterns for all services. A set of [TypeScript & JavaScript specific guidelines](https://azure.github.io/azure-sdk/typescript_introduction.html) was also introduced to ensure that these libraries have a natural and idiomatic feel. Further details are available in the guidelines for those interested.
1914

20-
In V1:
15+
The new version 7 of the Service Bus library provides the ability to share in some of the cross-service improvements made to the Azure development experience, such as using the new `@azure/identity` library to share a single authentication between clients and a unified diagnostics pipeline offering a common view of the activities across each of the client libraries.
2116

22-
```typescript
23-
const serviceBusClient = ServiceBusClient.fromConnectionString("connection string");
24-
```
17+
## Changes in version 7 of the Service Bus library
2518

26-
In V7:
19+
### Client hierarchy
2720

28-
```typescript
29-
const serviceBusClient = new ServiceBusClient("connection string");
30-
```
21+
In the interest of simplifying the API surface we've made a single top level client called `ServiceBusClient`, rather than one for each of queue, topic, and subscription. This acts as the single entry point in contrast with multiple entry points from before. You can create senders and receivers from this client to the queue/topic/subscription/session of your choice and start sending/receiving messages.
22+
23+
#### Approachability
24+
25+
By having a single entry point, the `ServiceBusClient` helps with the discoverability of the API as you can explore all available features through methods from a single client, as opposed to searching through documentation or exploring namespace for the types that you can instantiate. Whether sending or receiving, using sessions or not, you will start your applications by constructing the same client.
26+
27+
#### Consistency
28+
29+
We now have methods with similar names, signature and location to create senders and receivers. This provides consistency and predictability on the various features of the library.
30+
31+
### New features
32+
33+
We have a variety of new features in the version 7 of the Service Bus library.
34+
35+
- A new `ServiceBusAdministrationClient` to perform operations like create/get/list/update/delete on queues/topics/subscriptions/rules. These were already available as part of a separate package `@azure/arm-servicebus` that uses Azure Resouce Manager APIs but had the drawback of not supporting connection strings.
36+
- Ability to configure the retry policy used by the operations on the client, sender and receivers.
37+
- Ability to cancel async operations on the client, sender and receivers using the abort signal from `@azure/abort-controller`
38+
39+
### Client constructors
40+
41+
While previously, you would use the static method `createFromConnectionString` on the client to create it using connection string, now you can use the client constructor directly.
42+
43+
In V1:
44+
45+
```javascript
46+
const serviceBusClient = ServiceBusClient.createFromConnectionString("connection string");
47+
```
48+
49+
In V7:
50+
51+
```javascript
52+
const serviceBusClient = new ServiceBusClient("connection string");
53+
```
54+
55+
While previously, you would use the static method `createFromAadTokenCredentials` on the client to create it using Azure Active Directory, now you can use the new [@azure/identity](https://www.npmjs.com/package/@azure/identity) library to share a single authentication solution between clients of different Azure services.
56+
57+
In V1:
58+
59+
```javascript
60+
const { ServiceBusClient } = require("@azure/service-bus");
61+
const { interactiveLogin } = require("@azure/ms-rest-nodeauth");
62+
63+
const credential = await interactiveLogin({
64+
tokenAudience: "https://servicebus.azure.net/"
65+
});
66+
67+
const serviceBusClient = ServiceBusClient.createFromAadTokenCredentials(
68+
"my-namespace.servicebus.windows.net",
69+
credential
70+
);
71+
```
72+
73+
In V7:
74+
75+
```javascript
76+
const { ServiceBusClient } = require("@azure/service-bus");
77+
const { DefaultAzureCredential } = require("@azure/identity");
78+
79+
const credential = new DefaultAzureCredential();
80+
const serviceBusClient = new ServiceBusClient("my-namespace.servicebus.windows.net", credential);
81+
```
3182

3283
### Creating senders and receivers
3384

@@ -37,7 +88,7 @@ brings this package in line with the [Azure SDK Design Guidelines for Typescript
3788
In V1:
3889

3990
```typescript
40-
const serviceBusClient = ServiceBusClient.fromConnectionString("connection string");
91+
const serviceBusClient = ServiceBusClient.createFromConnectionString("connection string");
4192

4293
// for queues
4394
const queueClient = serviceBusClient.createQueueClient("queue");
@@ -73,9 +124,9 @@ brings this package in line with the [Azure SDK Design Guidelines for Typescript
73124
const subscriptionReceiver = serviceBusClient.createReceiver("topic", "subscription");
74125
```
75126

76-
- `createSessionReceiver()` method is now split into two async methods `acceptSession()` and `acceptNextSession()`
127+
- The `createReceiver()` overload that took session options is replaced by two async methods `acceptSession()` and `acceptNextSession()`
77128
- The promise returned by these methods is resolved when a receiver link has been initialized with a session in the service.
78-
- Prior to v7 `createSessionReceiver()` worked using lazy-initialization, where the
129+
- Prior to v7, `createReceiver()` worked using lazy-initialization, where the
79130
receiver link to the session was only initialized when the async methods on the `ServiceBusSessionReceiver`
80131
were first called.
81132

@@ -108,6 +159,13 @@ brings this package in line with the [Azure SDK Design Guidelines for Typescript
108159
});
109160
```
110161

162+
### Settling messages
163+
164+
Previously, the methods to settle messages (`complete()`, `abandon()`, `defer()` and `deadLetter()`) were on the messages themselves.
165+
These have been moved to the receiver in the new version, take the message as input and have the `Message` suffix in their name.
166+
The idea is to have the message represents just the data and not have the responsibility of any operation on the service side.
167+
Additionally, since a message cannot be settled if the receiver that was used to receive it is not alive, tying these operations to the receiver drives the message home better.
168+
111169
### Rule management
112170

113171
- The add/get/remove rule operations on the older `SubscriptionClient` have moved to the new `ServiceBusAdministrationClient` class which will be supporting

0 commit comments

Comments
 (0)