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

feat(iot-dev): Add support for Plug and Play feature over AMQP #1371

Merged
merged 14 commits into from
Sep 30, 2021

Conversation

timtay-microsoft
Copy link
Member

@timtay-microsoft timtay-microsoft commented Sep 27, 2021

Includes some multiplexing scenario PnP tests since customers will be trying PnP out in their protocol gateways

One interesting discussion we could have here is whether we need to release this in preview first or not. You'll notice that this PR doesn't make any API changes to enable this new feature, so I'm not worried about needing to make a breaking change in our API design later. With that in mind, I feel comfortable forgoing preview as long as we are committed to supporting PnP over AMQP. I'm open to hearing otherwise, though.

@timtay-microsoft timtay-microsoft marked this pull request as ready for review September 27, 2021 22:08
@Azure Azure deleted a comment from azure-pipelines bot Sep 27, 2021
@Azure Azure deleted a comment from azure-pipelines bot Sep 27, 2021
@Azure Azure deleted a comment from azure-pipelines bot Sep 27, 2021
@@ -28,7 +28,7 @@

AmqpsTelemetrySenderLinkHandler(Sender sender, AmqpsLinkStateCallback amqpsLinkStateCallback, DeviceClientConfig deviceClientConfig, String linkCorrelationId)
{
super(sender, amqpsLinkStateCallback, linkCorrelationId);
super(sender, amqpsLinkStateCallback, linkCorrelationId, deviceClientConfig.getModelId());
Copy link
Contributor

Choose a reason for hiding this comment

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

Does that mean deviceClientConfig will never be null? do we need a nullcheck?

Copy link
Member Author

Choose a reason for hiding this comment

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

It won't be null here, no

@jamdavi
Copy link
Member

jamdavi commented Sep 28, 2021

As part of PnP support we would need to add the componentName to the Message I would think. This would allow a customer to construct an Event (Telemetry) with the correct properties.

Or would this be out of scope for this particular implementation?

@timtay-microsoft
Copy link
Member Author

As part of PnP support we would need to add the componentName to the Message I would think. This would allow a customer to construct an Event (Telemetry) with the correct properties.

Or would this be out of scope for this particular implementation?

Isn't that transport agnostic? From the samples for PnP, I see that that twin message is constructed with the componentName, and then the message is sent just like any other.

assertEquals(response.getMetadata().getModelId(), E2ETestConstants.THERMOSTAT_MODEL_ID);
assertEquals(responseWithHeaders.body().getMetadata().getModelId(), E2ETestConstants.THERMOSTAT_MODEL_ID);

// act
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't love unit tests that get overly complicated beyond a single pass at arrange/act/assert.

Should this be 2 unit tests? Can the acts and asserts be grouped together?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is an integration test. I can remove one of the "act" blocks here, though


if (modelId != null && !modelId.isEmpty())
{
this.amqpProperties.put(Symbol.getSymbol(PNP_MODEL_ID_KEY), modelId);
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 to worry about URL escaping the model Id for AMQP? I forget. I know we had to for MQTT.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question. I'll take a look into this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like we don't need to. We URL escaped the model Id in MQTT because it was embedded into a URL. Here in AMQP though, it is just the value in a key-value pair. I checked, and we are not URL escaping the model Id for AMQP in the .NET SDK either.

@timtay-microsoft
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@jamdavi
Copy link
Member

jamdavi commented Sep 28, 2021

As part of PnP support we would need to add the componentName to the Message I would think. This would allow a customer to construct an Event (Telemetry) with the correct properties.
Or would this be out of scope for this particular implementation?

Isn't that transport agnostic? From the samples for PnP, I see that that twin message is constructed with the componentName, and then the message is sent just like any other.

It's only agnostic for Twin and Methods. For events we need to have the componentName and the correct system property. Abhipsa has the AMQP implementation in the below PR.

https://github.com/Azure/azure-iot-sdk-csharp/pull/1467/files

We weren't doing this in MQTT either for some reason
@timtay-microsoft
Copy link
Member Author

It's only agnostic for Twin and Methods. For events we need to have the componentName and the correct system property. Abhipsa has the AMQP implementation in the below PR.

I see. I pushed some changes to capture that then. I noticed that we weren't doing this in MQTT either, so I added the component name to the telemetry for both AMQP and MQTT

log.warn("Mqtt connection lost", throwable);

this.disconnect();

if (this.listener != null)
{
if (ex == null)
Copy link
Member Author

Choose a reason for hiding this comment

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

ex was always null, so I removed some unnecessary blocks of code here

@timtay-microsoft
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

if (message.isSecurityMessage())
{
userProperties.put(MessageProperty.IOTHUB_SECURITY_INTERFACE_ID, MessageProperty.IOTHUB_SECURITY_INTERFACE_ID_VALUE);
Copy link
Member Author

Choose a reason for hiding this comment

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

The security message property should have been in message annotations, not in user properties

timtay-microsoft and others added 2 commits September 29, 2021 14:23
…/iot/device/transport/mqtt/MqttMessaging.java

Co-authored-by: jamdavi <73593426+jamdavi@users.noreply.github.com>
…/iot/device/transport/amqps/AmqpsSenderLinkHandler.java

Co-authored-by: jamdavi <73593426+jamdavi@users.noreply.github.com>
@timtay-microsoft
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@timtay-microsoft
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants