How to route message to Service bus queue using routing query?

寵の児 提交于 2019-12-24 16:56:52

问题


I have an IoT hub with connected devices which sends telemetry messages. I want to read messages from each device separately, so I decided to create a different endpoint for each device. For sorting messages I use routes with query, but when I add a query rule to the route, messages stop going to the endpoint. Connected device uses MQTT.

Screenshots are below:

  • Endpoint
  • Routes
  • toMyEndpoint route

回答1:


Your query expression is correct.

But make sure you set content type and content encoding like this:

Message eventMessage = new Message(Encoding.UTF8.GetBytes("{\"boarded\":\"0\"}"));
eventMessage.ContentType = "application/json";
eventMessage.ContentEncoding = "utf-8";

It works for me.




回答2:


try to send a D2C message on the following topic:

devices/{yourDeviceId}/messages/events/$.ct=application%2Fjson&$.ce=utf-8

Note, that the content-encoding is utf-8.



来源:https://stackoverflow.com/questions/50985514/how-to-route-message-to-service-bus-queue-using-routing-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!