Skip to content

Enable Routing on Message Body #118

Closed

Description

  • OS and version used: Ubuntu 16.04

  • Java runtime used: Java(TM) SE Runtime Environment (build 1.8.0_131-b11)

  • SDK version used: <dependency> <groupId>com.microsoft.azure.sdk.iot</groupId> <artifactId>iot-device-client</artifactId> <version>1.3.30</version> </dependency>

Description of the issue:

I want to set the System Properties „ContentEncoding“ und „ContentType“ to enable routing on message body. As it mentioned in the article (https://azure.microsoft.com/de-de/blog/iot-hub-message-routing-now-with-routing-on-message-body/).

Actually, I see no possibilities to set these two system properties with this version of the SDK.

Do I got something wrong here?

Console log of the issue:

If is send a message with Java SDK it looks like:

12.07.2017 09:41:39> Device: [XXXXXXXXXXXXXXX], Data:[…]Properties:
'source': 'XXXXXXXXXXXXXXXXX'
SYSTEM>x-opt-sequence-number=1808
SYSTEM>x-opt-offset=1767872
SYSTEM>x-opt-enqueued-time=12.07.2017 07:41:39
SYSTEM>iothub-connection-device-id=XXXXXXXXXXXXXXXXXXX
SYSTEM>iothub-connection-auth-method={"scope":"device","type":"sas","issuer":"iothub","acceptingIpFilterRule":null}
SYSTEM>iothub-connection-auth-generation-id=XXXXXXXXXXXXXXXXXX
SYSTEM>iothub-enqueuedtime=12.07.2017 07:41:38
SYSTEM>iothub-message-source=Telemetry
SYSTEM>EnqueuedTimeUtc=12.07.2017 07:41:39
SYSTEM>SequenceNumber=1808
SYSTEM>Offset=1767872
SYSTEM>message-id=4646f130-14f5-4717-baf5-75591ef132b9
SYSTEM>correlation-id=921262c0-bc75-4c92-88b0-a06e94c689ea

And if is send a message with C# SDK and set the two propteries it looks like:
12.07.2017 09:43:52> Device: [XXXXXXXXXXXXXXX], Data:[...]Properties:
'Status': 'Active'
SYSTEM>x-opt-sequence-number=1234
SYSTEM>x-opt-offset=773528
SYSTEM>x-opt-enqueued-time=12.07.2017 07:43:52
SYSTEM>iothub-connection-device-id=XXXXXXXXXXXXXXX
SYSTEM>iothub-connection-auth-method={"scope":"device","type":"sas","issuer":"iothub","acceptingIpFilterRule":null}
SYSTEM>iothub-connection-auth-generation-id=XXXXXXXXXXXXXXX
SYSTEM>iothub-enqueuedtime=12.07.2017 07:43:51
SYSTEM>iothub-message-source=Telemetry
SYSTEM>EnqueuedTimeUtc=12.07.2017 07:43:52
SYSTEM>SequenceNumber=1234
SYSTEM>Offset=773528
SYSTEM>content-type=application/json
SYSTEM>content-encoding=utf-8

As far as i understand these last two properties are mandatory for routing on message body.

Best regards,

Activity

  1. changed the title [-]Enabling Routing on Message Body[/-] [+]Enable Routing on Message Body[/+] on Jul 13, 2017
  2. prmathur-microsoft commented on Jul 13, 2017

    @prmathur-microsoft
    Member

    Which protocol are you using to send properties ?

  3. it-bytes commented on Jul 14, 2017

    @it-bytes
    Author

    We are using the MQTT protocol. But in which way is this relevant? Shouldn't the com.microsoft.azure.sdk.iot.device.Message class not be independent from the chosen protocol?

    Additionally, I am aware that the DEFAULT_IOTHUB_MESSAGE_CHARSET is UTF-8, but as it is not reflected into the message system properties, I am not sure in which way the "SYSTEM>content-encoding=utf-8" is set implicitly.

    Best,

  4. it-bytes commented on Jul 18, 2017

    @it-bytes
    Author

    Hey there,
    is there any solution or suggestion forseeable?
    Thx

  5. prmathur-microsoft commented on Jul 18, 2017

    @prmathur-microsoft
    Member

    The protocol is relevant because it determines the way in which we set these headers. We are still investigating this issue.

  6. prmathur-microsoft commented on Jul 19, 2017

    @prmathur-microsoft
    Member

    We have identified some changes that should go in as part of SDK to enable routing. We have added it to our backlog and will work on it.

  7. it-bytes commented on Jul 20, 2017

    @it-bytes
    Author

    Thank you, I appreciate that.

  8. sandeeps05 commented on Jul 16, 2018

    @sandeeps05

    Hi, is there any solution formulated for this issue? Thanks!

  9. timtay-microsoft commented on Jul 16, 2018

    @timtay-microsoft
    Member

    We haven't had a chance to work on this lately. If you would like to provide a PR, we'd be happy to merge it in for you.

  10. sandeeps05 commented on Jul 16, 2018

    @sandeeps05

    Ok.. Just one more question, if I want to use 'Message.setProperty()' then should I set 'protocol = IotHubClientProtocol.AMQPS' (Or AMQP only supports metadata and MQTT doesn't) ?

  11. timtay-microsoft commented on Jul 16, 2018

    @timtay-microsoft
    Member

    All protocols support metadata, so you can set properties on a message regardless of protocol

  12. sandeeps05 commented on Jul 16, 2018

    @sandeeps05

    ok thanks for the response.. somehow setting MQTT-Metada combination didn't work for me and AMQP-metada worked like a charm!

  13. timtay-microsoft commented on Aug 20, 2018

    @timtay-microsoft
    Member

    Sorry for the really long delay on this issue, but we are now actively working on lighting up message routing for all protocols. Stay tuned.

  14. timtay-microsoft commented on Aug 30, 2018

    @timtay-microsoft
    Member

    The fix for this issue has been released as of Device Client 1.14.0, so I'm closing this issue now.

  15. az-iot-builder-01 commented on Aug 30, 2018

    @az-iot-builder-01
    Collaborator

    prmathur (@prmathur-microsoft), Dr. Paul Reinhold (@it-bytes), sandeeps84, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey

  16. DharitaChokshi commented on Sep 6, 2018

    @DharitaChokshi
  17. timtay-microsoft commented on Sep 6, 2018

    @timtay-microsoft
    Member

    What format is the message body that you are providing? And what encoding are you using to serialize it into a byte[]? Are you making sure to set the content encoding property of the message that matches that encoding?

    In the code sample you posted, it looks like you aren't setting either the contentEncoding or contentType on the message object. Assuming your message body is json, and you are using utf-8 to encoded that string, you need call

    msg.setContentType("application/json");
    msg.setContentEncoding(StandardCharsets.UTF_8.name());

    before sending the message

  18. timtay-microsoft commented on Sep 7, 2018

    @timtay-microsoft
    Member

    DharitaChokshi did my suggestions above help you, or are you still seeing an issue here?

  19. DharitaChokshi commented on Sep 9, 2018

    @DharitaChokshi

    Yes Tim Taylor (@timtay-microsoft), your suggestion did helped me. It is just the perfect thing that i was missing in my code. Thanks alot

    I have one more question. My Service Bus queue is receiving telemetry of 2 different objects. For Object1 is have to send mail to MailId1 and for Object2 j have to send mail to MailId2. Also i have to use some of the content from hson telemetry as body of my mail.
    For single object it is working fine. In my logic app i have used service bus followed by parse json and lastly stmp to send mail. In case i need to make decisions based kn json, what workflow i can use in LogicApp ?

  20. timtay-microsoft commented on Sep 10, 2018

    @timtay-microsoft
    Member

    I'm afraid I don't have much experience with setting up that kind of workflow in a Logic App. I recommend you reach out to a member of the logic apps team as they can help you better than I can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementfix checked inFix checked into main or preview, but not yet released.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions