Azure Service Bus: No messages on queue, only requ

2019-08-12 16:34发布

问题:

I'm trying to route messages from an IoT hub to a function app using a service bus queue as an Iot hub endpoint. The messages I send to the IoT hub are registered in the IoT hub, but won't be routed to the service bus queue. When I monitor the service bus queue, I only see successful requests.

I implemented two routing rules with the following criteria:

$._eventtype="meeting"

and

$body._eventtype="meeting"

I tested the second one with the example provided by Azure and it matched. Neither of them seem to forward the messages to the service bus.

Find below a sample message, which I'm trying to route.

{"_room": "-----", 
 "_eventtype": "meeting", 
 "_temperature": 25, 
 "_building": "-----", 
 "_timestamp": "2018-01-24T11:08:13.056792Z", 
 "_humidity": 36, 
 "_id": 0}

回答1:

Your Routes expression for message body is correct. It looks like, your event message is missing a Content type and Content encoding headers, see more details here.

In the case, when your device is MQTT direct connected, use the following topic, example for Device1:

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

for Http connected device:

content-encoding:utf-8
content-type:application/json


回答2:

In addition to @Roman Kiss points out, make sure you enable the listen permission of your Service Bus to receive messages.

You can follow "Read from the queue endpoint" to receive message routed to the service bus queue.



回答3:

You didn't mention the client or protocol, but if you are using the IoT Client SDK for Node.js and AMQP (perhaps MQTT too), then routing on body properties does not work.

This blog post implies it should, but a bug was only recently opened that indicates it has not been implemented.