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] add state property to ServiceBusReceivedMessage #18938

Merged
merged 9 commits into from
Dec 7, 2021

Conversation

jeremymeng
Copy link
Member

@jeremymeng jeremymeng commented Dec 2, 2021

It can be one of the three ServiceBusMessageState values: "active", "deferred", or "scheduled".

Several tests are updated to verify the message state property.

@azure-sdk
Copy link
Collaborator

API changes have been detected in @azure/core-amqp. You can review API changes here

API changes

+     readonly messageState: "x-opt-message-state";

@azure-sdk
Copy link
Collaborator

API changes have been detected in @azure/service-bus. You can review API changes here

API changes

+ export declare enum ServiceBusMessageState 
+     readonly state?: ServiceBusMessageState;

@@ -2,7 +2,7 @@
"name": "@azure/service-bus",
"sdk-type": "client",
"author": "Microsoft Corporation",
"version": "7.4.1",
"version": "7.5.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we normally release a beta first?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we havent discussed this with other languages yet, I would be ok with a beta. Otherwise, it is a straight forward feature that we could have gone GA directly with

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to 7.5.0-beta.1 for now.

… enum

A message's state is active if it is neither deferred nor scheduled.
@check-enforcer
Copy link

check-enforcer bot commented Dec 3, 2021

This pull request is protected by Check Enforcer.

What is Check Enforcer?

Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass.

Why am I getting this message?

You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged.

What should I do now?

If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows:
/check-enforcer evaluate
Typically evaulation only takes a few seconds. If you know that your pull request is not covered by a pipeline and this is expected you can override Check Enforcer using the following command:
/check-enforcer override
Note that using the override command triggers alerts so that follow-up investigations can occur (PRs still need to be approved as normal).

What if I am onboarding a new service?

Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment:
/azp run prepare-pipelines
This will run a pipeline that analyzes the source tree and creates the pipelines necessary to build and validate your pull request. Once the pipeline has been created you can trigger the pipeline using the following comment:
/azp run js - [service] - ci

@azure-sdk
Copy link
Collaborator

API changes have been detected in @azure/service-bus. You can review API changes here

API changes

+     readonly state: "active" | "deferred" | "scheduled";

@@ -7,6 +7,7 @@
- Changed TS compilation target to ES2017 in order to produce smaller bundles and use more native platform features
- With the dropping of support for Node.js versions that are no longer in LTS, the dependency on `@types/node` has been updated to version 12. Read our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
- Updated to use the latest version of the `rhea` package.
- Add a constant `messageState` with value of `"x-opt-message-state"`. [PR 18938](https://github.com/Azure/azure-sdk-for-js/pull/18938)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Add a constant `messageState` with value of `"x-opt-message-state"`. [PR 18938](https://github.com/Azure/azure-sdk-for-js/pull/18938)
- Add a constant `messageState` with value of `"x-opt-message-state"` to be used as property name for the new state property on the message. [PR 18938](https://github.com/Azure/azure-sdk-for-js/pull/18938)


### Features Added

- Add `state` property `ServiceBusReceivedMessage`. Its value is one of `"active"`, `"deferred"`, or `"scheduled"`. [PR 18938](https://github.com/Azure/azure-sdk-for-js/pull/18938)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Add `state` property `ServiceBusReceivedMessage`. Its value is one of `"active"`, `"deferred"`, or `"scheduled"`. [PR 18938](https://github.com/Azure/azure-sdk-for-js/pull/18938)
- Add `state` property to `ServiceBusReceivedMessage`. Its value is one of `"active"`, `"deferred"`, or `"scheduled"`. [PR 18938](https://github.com/Azure/azure-sdk-for-js/pull/18938)

if (rheaMessage.message_annotations != null) {
if (rheaMessage.message_annotations[Constants.deadLetterSource] != null) {
props.deadLetterSource = rheaMessage.message_annotations[Constants.deadLetterSource];
}
const messageState = rheaMessage.message_annotations[Constants.messageState];
if (isDefined(messageState) && (messageState === 1 || messageState === 2)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the isDefined check here? Won't the below just work without the defined check?

if (messageState === 1) {
   props.state = "deferred";
} else if (messageState === 2) {
   props.state = "scheduled";
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is enough. IsDefined() is from previous iteration that no longer needed.

@@ -905,6 +923,7 @@ export class ServiceBusMessageImpl implements ServiceBusReceivedMessage {
this._rawAmqpMessage = _rawAmqpMessage;
this._rawAmqpMessage.bodyType = actualBodyType;
this.delivery = delivery;
this.state = restOfMessageProps.state;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesnt the Object.assign(this, restOfMessageProps); at line 902 take care of assigning the state?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeScript compiler is not smart enough to detect that. I added some comments.

@ramya-rao-a
Copy link
Contributor

Looks like the build is failing due to a missing rush update

@@ -1132,6 +1132,29 @@ packages:
- supports-color
dev: false

/@azure/service-bus/7.4.0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which part of our repo depend on this version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eventgrid and perf-service-bus depends on ^7.0.0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. It may not be worth it to make perf-service-bus depend on this beta but perhaps something to consider.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at history and we haven't done that for older versions. Though we probably want perf tests to always use source version @HarshaNalluru?

@jeremymeng jeremymeng merged commit b7638dc into Azure:main Dec 7, 2021
@jeremymeng jeremymeng deleted the sb/message-state branch December 7, 2021 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants