diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/AmqpMessageConverter.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/AmqpMessageConverter.cs index 9fa5f3e07fa..747ab6ccd12 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/AmqpMessageConverter.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/AmqpMessageConverter.cs @@ -165,6 +165,16 @@ public AmqpMessage FromMessage(IMessage message) amqpMessage.MessageAnnotations.Map[Constants.MessageAnnotationsInputNameKey] = inputName; } + if (message.SystemProperties.TryGetNonEmptyValue(SystemProperties.ConnectionDeviceId, out string connectionDeviceId)) + { + amqpMessage.MessageAnnotations.Map[Constants.MessageAnnotationsConnectionDeviceId] = connectionDeviceId; + } + + if (message.SystemProperties.TryGetNonEmptyValue(SystemProperties.ConnectionModuleId, out string connectionModuleId)) + { + amqpMessage.MessageAnnotations.Map[Constants.MessageAnnotationsConnectionModuleId] = connectionModuleId; + } + if (message.SystemProperties.TryGetNonEmptyValue(SystemProperties.MessageSchema, out string messageSchema)) { amqpMessage.ApplicationProperties.Map[Constants.MessagePropertiesMessageSchemaKey] = messageSchema; diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Constants.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Constants.cs index ca79fcf20c8..66ab4b5f950 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Constants.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Constants.cs @@ -35,5 +35,7 @@ public static class Constants public const string MessagePropertiesOutputNameKey = "iothub-outputname"; public const string MessagePropertiesMethodNameKey = "IoThub-methodname"; public const string MessageAnnotationsInputNameKey = "x-opt-input-name"; + public const string MessageAnnotationsConnectionDeviceId = "iothub-connection-device-id"; + public const string MessageAnnotationsConnectionModuleId = "iothub-connection-module-id"; } } diff --git a/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Amqp.Test/AmqpMessageConverterTest.cs b/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Amqp.Test/AmqpMessageConverterTest.cs index 42bf56b668a..d3622cba764 100644 --- a/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Amqp.Test/AmqpMessageConverterTest.cs +++ b/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Amqp.Test/AmqpMessageConverterTest.cs @@ -235,6 +235,8 @@ public void FromMessageTest_AllProperties() string operation = "foo"; string inputName = "inputName"; string outputName = "outputName"; + string connectionDeviceId = "edgeDevice1"; + string connectionModuleId = "module1"; var systemProperties = new Dictionary { @@ -253,7 +255,9 @@ public void FromMessageTest_AllProperties() [SystemProperties.CreationTime] = creationTime, [SystemProperties.Operation] = operation, [SystemProperties.InputName] = inputName, - [SystemProperties.OutputName] = outputName + [SystemProperties.OutputName] = outputName, + [SystemProperties.ConnectionDeviceId] = connectionDeviceId, + [SystemProperties.ConnectionModuleId] = connectionModuleId }; var properties = new Dictionary @@ -294,6 +298,8 @@ byte[] GetMessageBody(AmqpMessage sourceMessage) Assert.Equal(lockToken, amqpMessage.MessageAnnotations.Map[Amqp.Constants.MessageAnnotationsLockTokenName]); Assert.Equal(sequenceNumber, amqpMessage.MessageAnnotations.Map[Amqp.Constants.MessageAnnotationsSequenceNumberName]); Assert.Equal(inputName, amqpMessage.MessageAnnotations.Map[Amqp.Constants.MessageAnnotationsInputNameKey]); + Assert.Equal(connectionDeviceId, amqpMessage.MessageAnnotations.Map[Amqp.Constants.MessageAnnotationsConnectionDeviceId]); + Assert.Equal(connectionModuleId, amqpMessage.MessageAnnotations.Map[Amqp.Constants.MessageAnnotationsConnectionModuleId]); Assert.Equal(messageSchema, amqpMessage.ApplicationProperties.Map[Amqp.Constants.MessagePropertiesMessageSchemaKey]); Assert.Equal(creationTime, amqpMessage.ApplicationProperties.Map[Amqp.Constants.MessagePropertiesCreationTimeKey]);