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

[event-hubs] set known amqp props on systemProperties #7973

Merged
merged 4 commits into from
Mar 25, 2020

Conversation

chradek
Copy link
Contributor

@chradek chradek commented Mar 24, 2020

Fixes #7801

Since systemProperties was already an object with an index signature of string to any, no API changes were needed to support this.

It also turned out every one of the properties added is a typed field on the amqp message.

@chradek chradek added Client This issue points to a problem in the data-plane of the library. Event Hubs labels Mar 24, 2020
/**
* Converts the AMQP message to an EventData.
* @param msg The AMQP message that needs to be converted to EventData.
* @ignore
*/
export function fromAmqpMessage(msg: Message): EventDataInternal {
const data: EventDataInternal = {
body: msg.body
body: msg.body,
systemProperties: {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Any concern that in the absence of any system properties, this would be undefined before this PR and moving forward, it would be empty object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don’t think so. Really, I think it will nearly, if not always be defined now given all the new properties that can be added (for example, the to field). This reduces the number of times we had to check if the object already existed and doesn't hurt the API (if anything I think of we made it a required property that makes things easier by removing an existence check.)

That said, it could lead to more objects being allocated which isn’t free if none of the properties exist. I was testing with iothub events but can check with plain event hub events to see if they are ever all undefined.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was testing with iothub events but can check with plain event hub events to see if they are ever all undefined

Lets do that

Copy link
Contributor Author

@chradek chradek Mar 24, 2020

Choose a reason for hiding this comment

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

All the new properties can be undefined if sending a message with just a body using to event hubs.

I still think it's ok to return an empty object for systemProperties from an API perspective but I can revert that if you have concerns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted. Favoring memory optimization over (potentially) compute.

@@ -2,6 +2,8 @@

## 5.0.3 (Unreleased)

- Fixes an issue where known properties were not being set on a received event's `systemProperties`.
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
- Fixes an issue where known properties were not being set on a received event's `systemProperties`.
- Fixes [issue #7801](https://github.com/Azure/azure-sdk-for-js/pull/7973) where known properties were not being set on a received event's `systemProperties`.

I wonder if we should call this out as a "feature request". It didn't exist in previous versions of the library either

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds fair enough. I can change the wording and update the version accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@chradek
Copy link
Contributor Author

chradek commented Mar 24, 2020

/azp run js - eventhubs-client - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@chradek chradek merged commit c42cb7d into Azure:master Mar 25, 2020
@chradek chradek deleted the eh-move-amqp-props branch March 25, 2020 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Event Hubs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing systemProperties when consuming messages from IoTHub
2 participants