Azure / azure-event-hubs-c

C client library for Azure Event Hubs https://azure.microsoft.com/services/event-hubs
Other
7 stars 18 forks source link

Accessing system properties #38

Closed AntoineGagne closed 3 years ago

AntoineGagne commented 5 years ago

Hi everyone,

Is there any way to access the system properties (i.e. accessing a property such as iothub-connection-device-id). In the other SDKs, I have seen some methods to be able to access them, but I have not seen a way to do the same with this SDK.

Thank you!

dcristoloveanu commented 5 years ago

When receiving the receiver gets the application properties from the AMQP message, so it should be possible to get all the IoTHub properties that are stuck in the application properties from the event data by using EventData_Properties.

IIRC correctly the IoT Hub properties are packaged in the application properties of the AMQP message.

I did not get to try the specific property on the latest master. Once I do I’ll reply here.

Benjamin118 commented 4 years ago

Hi everyone,

I agree with @AntoineGagne : Iothub client knows the notion of system properties (as MessageId or MessageCorrelationId), not to be confused with user (or custom) properties associated to the message.

With using EventData_Properties, we only have access on user properties, and eventDataHandle doesn't contain system properties (see attached log)

We need these system properties to check full integrity of received message on eventHub.

EventHub_Issue_38_system_properties_missing.log

alexmrtn commented 4 years ago

Hi,

I did some additional instigation and there is indeed a missing piece here. The properties on a received event does not contains the message ID.

I checked in the azure-iot-c-sdk repo, the AMQP transport protocol uses properties_set_message_id function to set on the AMQP message the user-defined message ID of the IOTHUB_MESSAGE_HANDLE. However in this repo the corresponding properties_get_message_id is never used when the AMQP message is transformed to a EVENTDATA_HANDLE.

How can we solve this without having to use a custom property for the message ID ?

Thanks!

anthonyvercolano commented 3 years ago

@AntoineGagne
This is from Node, but this is the actual location of the device id. if (eventData.annotations['iothub-connection-device-id'] === provisionedDevice.deviceId) @dcristoloveanu & @Benjamin118

anthonyvercolano commented 3 years ago

Really using the C SDK to get this isn't the best path. Use something like the azure node event hub sdk which can provide what you need. Probably the C# one does also.