问题
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