Skip to content

Commit

Permalink
[Service Bus] Msg property renames, sku enums, mandatory sqlExpressio…
Browse files Browse the repository at this point in the history
…n in rules Azure#11701 (Azure#11782)
  • Loading branch information
mohsin-mehmood authored Oct 16, 2020
1 parent 5646d4b commit 1152ea0
Show file tree
Hide file tree
Showing 16 changed files with 150 additions and 106 deletions.
11 changes: 11 additions & 0 deletions sdk/servicebus/service-bus/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
- [Bug Fix] `sendMessages` method on the sender would have previously thrown an error for sending a batch or an array of messages upon a network disconnect, the issue has been fixed now.
[PR 11651](https://github.com/Azure/azure-sdk-for-js/pull/11651/commits/f262e4562eb78828ee816a54f9a9778692e0eff9)

- Added new "userId" property to `ServiceBusMessage` interface. [PR 11810](https://github.com/Azure/azure-sdk-for-js/pull/11810)

- `NamespaceProperties` interface property "messageSku" type changed from "string" to string literal type "Basic" | "Premium" | "Standard". [PR 11810](https://github.com/Azure/azure-sdk-for-js/pull/11810)

### New features:

- Message locks can be auto-renewed in all receive methods (receiver.receiveMessages, receiver.subcribe
Expand All @@ -32,6 +36,13 @@
- `acceptSession`, which opens a session by name
- `acceptNextSession`, which opens the next available session, determined by Service Bus.
- as part of this `CreateSessionReceiverOptions` has been renamed to `AcceptSessionReceiverOptions` to conform to guidelines.
- `ServiceBusMessage` interface updates:
- "properties" renamed to "applicationProperties"
- "label" renamed to "subject"
- `CorrelationRuleFilter` interface updates:
- "properties" renamed to "applicationProperties"
- "label" renamed to "subject"
- `SqlRuleFilter` interface "sqlExpression" changed from optional to required

## 7.0.0-preview.6 (2020-09-10)

Expand Down
21 changes: 11 additions & 10 deletions sdk/servicebus/service-bus/review/service-bus.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ export type AuthorizationRule = {

// @public
export interface CorrelationRuleFilter {
applicationProperties?: {
[key: string]: string | number | boolean | Date;
};
contentType?: string;
correlationId?: string;
label?: string;
messageId?: string;
properties?: {
[key: string]: string | number | boolean | Date;
};
replyTo?: string;
replyToSessionId?: string;
sessionId?: string;
subject?: string;
to?: string;
}

Expand Down Expand Up @@ -202,7 +202,7 @@ export { MessagingError }
// @public
export interface NamespaceProperties {
createdAt: Date;
messagingSku: string;
messagingSku: "Basic" | "Premium" | "Standard";
messagingUnits: number | undefined;
modifiedAt: Date;
name: string;
Expand Down Expand Up @@ -363,21 +363,22 @@ export interface ServiceBusClientOptions {

// @public
export interface ServiceBusMessage {
applicationProperties?: {
[key: string]: number | boolean | string | Date;
};
body: any;
contentType?: string;
correlationId?: string | number | Buffer;
label?: string;
messageId?: string | number | Buffer;
partitionKey?: string;
properties?: {
[key: string]: number | boolean | string | Date;
};
replyTo?: string;
replyToSessionId?: string;
scheduledEnqueueTimeUtc?: Date;
sessionId?: string;
subject?: string;
timeToLive?: number;
to?: string;
userId?: string;
viaPartitionKey?: string;
}

Expand Down Expand Up @@ -472,7 +473,7 @@ export type SqlRuleAction = {

// @public
export interface SqlRuleFilter {
sqlExpression?: string;
sqlExpression: string;
sqlParameters?: {
[key: string]: string | number | boolean;
};
Expand Down
18 changes: 9 additions & 9 deletions sdk/servicebus/service-bus/src/core/managementClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ export interface CorrelationRuleFilter {
*/
replyTo?: string;
/**
* Value to be matched with the `label` property of the incoming message.
* Value to be matched with the `subject` property of the incoming message.
*/
label?: string;
subject?: string;
/**
* Value to be matched with the `sessionId` property of the incoming message.
*/
Expand All @@ -125,7 +125,7 @@ export interface CorrelationRuleFilter {
/**
* Value to be matched with the user properties of the incoming message.
*/
properties?: { [key: string]: string | number | boolean | Date };
applicationProperties?: { [key: string]: string | number | boolean | Date };
}

/**
Expand All @@ -137,11 +137,11 @@ const correlationProperties = [
"messageId",
"to",
"replyTo",
"label",
"subject",
"sessionId",
"replyToSessionId",
"contentType",
"properties"
"applicationProperties"
];

/**
Expand Down Expand Up @@ -1140,11 +1140,11 @@ export class ManagementClient extends LinkEntity<RequestResponseLink> {
messageId: this._safelyGetTypedValueFromArray(filtersRawData.value, 1),
to: this._safelyGetTypedValueFromArray(filtersRawData.value, 2),
replyTo: this._safelyGetTypedValueFromArray(filtersRawData.value, 3),
label: this._safelyGetTypedValueFromArray(filtersRawData.value, 4),
subject: this._safelyGetTypedValueFromArray(filtersRawData.value, 4),
sessionId: this._safelyGetTypedValueFromArray(filtersRawData.value, 5),
replyToSessionId: this._safelyGetTypedValueFromArray(filtersRawData.value, 6),
contentType: this._safelyGetTypedValueFromArray(filtersRawData.value, 7),
properties: this._safelyGetTypedValueFromArray(filtersRawData.value, 8)
applicationProperties: this._safelyGetTypedValueFromArray(filtersRawData.value, 8)
};
break;
default:
Expand Down Expand Up @@ -1265,11 +1265,11 @@ export class ManagementClient extends LinkEntity<RequestResponseLink> {
"message-id": filter.messageId,
to: filter.to,
"reply-to": filter.replyTo,
label: filter.label,
subject: filter.subject,
"session-id": filter.sessionId,
"reply-to-session-id": filter.replyToSessionId,
"content-type": filter.contentType,
properties: filter.properties
applicationProperties: filter.applicationProperties
};
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ export function instrumentServiceBusMessage(
message: ServiceBusMessage,
span: Span
): ServiceBusMessage {
if (message.properties && message.properties[TRACEPARENT_PROPERTY]) {
if (message.applicationProperties && message.applicationProperties[TRACEPARENT_PROPERTY]) {
return message;
}

// create a copy so the original isn't modified
message = { ...message, properties: { ...message.properties } };
message = { ...message, applicationProperties: { ...message.applicationProperties } };

const traceParent = getTraceParentHeader(span.context());
if (traceParent) {
message.properties![TRACEPARENT_PROPERTY] = traceParent;
message.applicationProperties![TRACEPARENT_PROPERTY] = traceParent;
}

return message;
Expand All @@ -54,11 +54,11 @@ export function instrumentServiceBusMessage(
export function extractSpanContextFromServiceBusMessage(
message: ServiceBusMessage
): SpanContext | undefined {
if (!message.properties || !message.properties[TRACEPARENT_PROPERTY]) {
if (!message.applicationProperties || !message.applicationProperties[TRACEPARENT_PROPERTY]) {
return;
}

const diagnosticId = message.properties[TRACEPARENT_PROPERTY] as string;
const diagnosticId = message.applicationProperties[TRACEPARENT_PROPERTY] as string;
return extractSpanContextFromTraceParentHeader(diagnosticId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface NamespaceProperties {
* The SKU/tier of the namespace.
* "Basic", "Standard" and "Premium"
*/
messagingSku: string;
messagingSku: "Basic" | "Premium" | "Standard";
/**
* The last time at which the namespace was modified.
*/
Expand Down Expand Up @@ -53,7 +53,9 @@ export interface NamespaceProperties {
* @param rawNamespace
*/
export function buildNamespace(rawNamespace: any): NamespaceProperties {
const messagingSku = getString(rawNamespace["MessagingSKU"], "messagingSku");
const messagingSku = <"Basic" | "Premium" | "Standard">(
getString(rawNamespace["MessagingSKU"], "messagingSku")
);
return {
createdAt: getDate(rawNamespace["CreatedTime"], "createdAt"),
messagingSku: messagingSku,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ function getTopicFilter(value: any): SqlRuleFilter | CorrelationRuleFilter {
} else {
result = {
correlationId: getStringOrUndefined(value["CorrelationId"]),
label: getStringOrUndefined(value["Label"]),
subject: getStringOrUndefined(value["Label"]),
to: getStringOrUndefined(value["To"]),
replyTo: getStringOrUndefined(value["ReplyTo"]),
replyToSessionId: getStringOrUndefined(value["ReplyToSessionId"]),
sessionId: getStringOrUndefined(value["SessionId"]),
messageId: getStringOrUndefined(value["MessageId"]),
contentType: getStringOrUndefined(value["ContentType"]),
properties: getKeyValuePairsOrUndefined(value["Properties"], "UserProperties")
applicationProperties: getKeyValuePairsOrUndefined(
value["Properties"],
"ApplicationProperties"
)
};
}
return result;
Expand Down Expand Up @@ -143,7 +146,7 @@ export interface SqlRuleFilter {
* SQL expression to use in the rule filter.
* Defaults to creating a true filter if none specified
*/
sqlExpression?: string;
sqlExpression: string;

/**
* SQL parameters to the SQL expression in the rule filter.
Expand Down Expand Up @@ -189,14 +192,17 @@ export class RuleResourceSerializer implements AtomXmlSerializer {

resource.Filter = {
CorrelationId: correlationFilter.correlationId,
Label: correlationFilter.label,
Label: correlationFilter.subject,
To: correlationFilter.to,
ReplyTo: correlationFilter.replyTo,
ReplyToSessionId: correlationFilter.replyToSessionId,
ContentType: correlationFilter.contentType,
SessionId: correlationFilter.sessionId,
MessageId: correlationFilter.messageId,
Properties: buildInternalRawKeyValuePairs(correlationFilter.properties, "userProperties")
Properties: buildInternalRawKeyValuePairs(
correlationFilter.applicationProperties,
"applicationProperties"
)
};
resource.Filter[Constants.XML_METADATA_MARKER] = {
"p4:type": "CorrelationFilter",
Expand Down Expand Up @@ -300,7 +306,7 @@ const keyValuePairXMLTag = "KeyValueOfstringanyType";
*/
function getKeyValuePairsOrUndefined(
value: any,
attribute: "UserProperties" | "SQLParameters"
attribute: "ApplicationProperties" | "SQLParameters"
): { [key: string]: any } | undefined {
if (!value) {
return undefined;
Expand Down Expand Up @@ -353,7 +359,7 @@ function getKeyValuePairsOrUndefined(
*/
export function buildInternalRawKeyValuePairs(
parameters: { [key: string]: any } | undefined,
attribute: "userProperties" | "sqlParameters"
attribute: "applicationProperties" | "sqlParameters"
): InternalRawKeyValuePairs | undefined {
if (parameters == undefined) {
return undefined;
Expand Down
Loading

0 comments on commit 1152ea0

Please sign in to comment.