Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Servicebus remove viapartitionkey #12026

Merged
1 change: 1 addition & 0 deletions sdk/servicebus/service-bus/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- `ServiceBusSender.scheduleMessages` method signature updated: `scheduledEnqueueTimeUtc` and `messages` parameters are swapped.
- Interfaces corresponding to the returned responses from the methods under the `ServiceBusAdministrationClient` such as `NamespacePropertiesResponse`, `QueueResponse`, `TopicRuntimePropertiesResponse` have been removed in favor of using generic type `WithResponse<T>` for a cleaner API surface.
[PR 10491](https://github.com/Azure/azure-sdk-for-js/pull/10491)
- `viaPartitionKey` property of interface `ServiceMessageBus` has been removed until we implement the [Transactions feature of Service Bus](https://docs.microsoft.com/azure/service-bus-messaging/service-bus-transactions).

## 7.0.0-preview.7 (2020-10-07)

Expand Down
1 change: 0 additions & 1 deletion sdk/servicebus/service-bus/review/service-bus.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ export interface ServiceBusMessage {
timeToLive?: number;
to?: string;
userId?: string;
viaPartitionKey?: string;
}

// @public
Expand Down
8 changes: 5 additions & 3 deletions sdk/servicebus/service-bus/src/core/managementClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,11 @@ export class ManagementClient extends LinkEntity<RequestResponseLink> {
if (item.partitionKey) {
entry["partition-key"] = item.partitionKey;
}
if (item.viaPartitionKey) {
entry["via-partition-key"] = item.viaPartitionKey;
}
mohsin-mehmood marked this conversation as resolved.
Show resolved Hide resolved

// Will be required later for implementing Transactions
// if (item.viaPartitionKey) {
// entry["via-partition-key"] = item.viaPartitionKey;
// }

const wrappedEntry = types.wrap_map(entry);
messageBody.push(wrappedEntry);
Expand Down
41 changes: 26 additions & 15 deletions sdk/servicebus/service-bus/src/serviceBusMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ export interface ServiceBusMessage {
* together and in order as they are transferred.
* See {@link https://docs.microsoft.com/azure/service-bus-messaging/service-bus-transactions#transfers-and-send-via Transfers and Send Via}.
*/
viaPartitionKey?: string;

// Will be required later for implementing Transactions
// viaPartitionKey?: string;

/**
* @property The session identifier for a session-aware entity. Maximum
* length is 128 characters. For session-aware entities, this application-defined value specifies
Expand Down Expand Up @@ -466,14 +469,17 @@ export function toAmqpMessage(msg: ServiceBusMessage): AmqpMessage {
}
amqpMsg.message_annotations![Constants.partitionKey] = msg.partitionKey;
}
if (msg.viaPartitionKey != null) {
if (msg.viaPartitionKey.length > Constants.maxPartitionKeyLength) {
throw new Error(
"Length of 'viaPartitionKey' property on the message cannot be greater than 128 characters."
);
}
amqpMsg.message_annotations![Constants.viaPartitionKey] = msg.viaPartitionKey;
}

// Will be required later for implementing Transactions
// if (msg.viaPartitionKey != null) {
// if (msg.viaPartitionKey.length > Constants.maxPartitionKeyLength) {
// throw new Error(
// "Length of 'viaPartitionKey' property on the message cannot be greater than 128 characters."
// );
// }
// amqpMsg.message_annotations![Constants.viaPartitionKey] = msg.viaPartitionKey;
// }

if (msg.scheduledEnqueueTimeUtc != null) {
amqpMsg.message_annotations![Constants.scheduledEnqueueTime] = msg.scheduledEnqueueTimeUtc;
}
Expand Down Expand Up @@ -626,9 +632,12 @@ export function fromAmqpMessage(
if (msg.message_annotations[Constants.partitionKey] != null) {
sbmsg.partitionKey = msg.message_annotations[Constants.partitionKey];
}
if (msg.message_annotations[Constants.viaPartitionKey] != null) {
sbmsg.viaPartitionKey = msg.message_annotations[Constants.viaPartitionKey];
}

// Will be required later for implementing Transactions
// if (msg.message_annotations[Constants.viaPartitionKey] != null) {
// sbmsg.viaPartitionKey = msg.message_annotations[Constants.viaPartitionKey];
// }

if (msg.message_annotations[Constants.scheduledEnqueueTime] != null) {
sbmsg.scheduledEnqueueTimeUtc = msg.message_annotations[Constants.scheduledEnqueueTime];
}
Expand Down Expand Up @@ -778,7 +787,8 @@ export class ServiceBusMessageImpl implements ServiceBusReceivedMessage {
* together and in order as they are transferred.
* See {@link https://docs.microsoft.com/azure/service-bus-messaging/service-bus-transactions#transfers-and-send-via Transfers and Send Via}.
*/
viaPartitionKey?: string;
// Will be required later for implementing Transactions
// viaPartitionKey?: string;
/**
* @property The session identifier for a session-aware entity. Maximum
* length is 128 characters. For session-aware entities, this application-defined value specifies
Expand Down Expand Up @@ -1078,8 +1088,9 @@ export class ServiceBusMessageImpl implements ServiceBusReceivedMessage {
sessionId: this.sessionId,
timeToLive: this.timeToLive,
to: this.to,
applicationProperties: this.applicationProperties,
viaPartitionKey: this.viaPartitionKey
applicationProperties: this.applicationProperties
// Will be required later for implementing Transactions
// viaPartitionKey: this.viaPartitionKey
};

return clone;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("ServiceBusMessageImpl AmqpAnnotations unit tests", () => {
const message_annotations: MessageAnnotations = {};
message_annotations[Constants.enqueuedTime] = Date.now();
message_annotations[Constants.partitionKey] = "dummy-partition-key";
message_annotations[Constants.viaPartitionKey] = "dummy-via-partition-key";
//message_annotations[Constants.viaPartitionKey] = "dummy-via-partition-key";
message_annotations["random-msg-annotation-key"] = "random-msg-annotation-value";

const delivery_annotations: DeliveryAnnotations = {
Expand Down Expand Up @@ -135,11 +135,12 @@ describe("ServiceBusMessageImpl AmqpAnnotations unit tests", () => {
message_annotations[Constants.partitionKey],
"Unexpected Partition Key"
);
assert.equal(
sbMessage.viaPartitionKey,
message_annotations[Constants.viaPartitionKey],
"Unexpected Via Partition Key"
);

// assert.equal(
// sbMessage.viaPartitionKey,
// message_annotations[Constants.viaPartitionKey],
// "Unexpected Via Partition Key"
// );
});

it("delivery annotations match", () => {
Expand Down
12 changes: 6 additions & 6 deletions sdk/servicebus/service-bus/test/sendAndSchedule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,12 @@ describe("ServiceBusMessage validations", function(): void {
"Length of 'partitionKey' property on the message cannot be greater than 128 characters.",
title: "partitionKey is longer than 128 characters"
},
{
message: { body: "", viaPartitionKey: longString },
expectedErrorMessage:
"Length of 'viaPartitionKey' property on the message cannot be greater than 128 characters.",
title: "viaPartitionKey is longer than 128 characters"
},
// {
// message: { body: "", viaPartitionKey: longString },
// expectedErrorMessage:
// "Length of 'viaPartitionKey' property on the message cannot be greater than 128 characters.",
// title: "viaPartitionKey is longer than 128 characters"
// },
{
message: { body: "", sessionId: longString },
expectedErrorMessage:
Expand Down