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
Prev Previous commit
[servicebus]Comment out the code referncing viaPartitionKey instead o…
…f deleting it
Mohsin Mehmood committed Oct 26, 2020
commit ffc549592a0602c557bfeb74958726a5a46cfb65
2 changes: 1 addition & 1 deletion sdk/servicebus/service-bus/src/core/managementClient.ts
Original file line number Diff line number Diff line change
@@ -600,7 +600,7 @@ export class ManagementClient extends LinkEntity<RequestResponseLink> {
entry["partition-key"] = item.partitionKey;
}

// Will be required later for implementing [Transactions feature of Service Bus](https://docs.microsoft.com/azure/service-bus-messaging/service-bus-transactions).
// Will be required later for implementing Transactions
// if (item.viaPartitionKey) {
// entry["via-partition-key"] = item.viaPartitionKey;
// }
39 changes: 39 additions & 0 deletions sdk/servicebus/service-bus/src/serviceBusMessage.ts
Original file line number Diff line number Diff line change
@@ -140,6 +140,18 @@ export interface ServiceBusMessage {
*
*/
partitionKey?: string;
/**
* @property The partition key for sending a message into an entity
* via a partitioned transfer queue. Maximum length is 128 characters. If a message is sent via a
* transfer queue in the scope of a transaction, this value selects the transfer queue partition:
* This is functionally equivalent to `partitionKey` property and ensures that messages are kept
* 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}.
*/

// 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
@@ -458,6 +470,16 @@ export function toAmqpMessage(msg: ServiceBusMessage): AmqpMessage {
amqpMsg.message_annotations![Constants.partitionKey] = msg.partitionKey;
}

// 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;
}
@@ -611,6 +633,11 @@ export function fromAmqpMessage(
sbmsg.partitionKey = msg.message_annotations[Constants.partitionKey];
}

// 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];
}
@@ -752,6 +779,16 @@ export class ServiceBusMessageImpl implements ServiceBusReceivedMessage {
* the `sessionId` property overrides this value.
*/
partitionKey?: string;
/**
* @property The partition key for sending a message into an entity
* via a partitioned transfer queue. Maximum length is 128 characters. If a message is sent via a
* transfer queue in the scope of a transaction, this value selects the transfer queue partition:
* This is functionally equivalent to `partitionKey` property and ensures that messages are kept
* 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}.
*/
// 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
@@ -1052,6 +1089,8 @@ export class ServiceBusMessageImpl implements ServiceBusReceivedMessage {
timeToLive: this.timeToLive,
to: this.to,
applicationProperties: this.applicationProperties
// Will be required later for implementing Transactions
// viaPartitionKey: this.viaPartitionKey
};

return clone;
Original file line number Diff line number Diff line change
@@ -62,6 +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["random-msg-annotation-key"] = "random-msg-annotation-value";

const delivery_annotations: DeliveryAnnotations = {
@@ -134,6 +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"
// );
});

it("delivery annotations match", () => {
6 changes: 6 additions & 0 deletions sdk/servicebus/service-bus/test/sendAndSchedule.spec.ts
Original file line number Diff line number Diff line change
@@ -445,6 +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: "", sessionId: longString },
expectedErrorMessage: