You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| Service | Sender link |`/messages/devicebound`| C2D messages destined to devices are sent to this link by the service. Messages sent over this link have their `To` property set to the target device's receiver link path: i.e., `/devices/<deviceID>/messages/devicebound`. |
63
-
| Service | Receiver link |`/messages/serviceBound/feedback`| Completion, rejection, and abandonment feedback messages coming from devices received on this link by service. See [here](./iot-hub-devguide-messages-c2d.md#message-feedback) for more information about feedback messages. |
63
+
| Service | Receiver link |`/messages/serviceBound/feedback`| Completion, rejection, and abandonment feedback messages coming from devices received on this link by service. For more information about feedback messages, see [here](./iot-hub-devguide-messages-c2d.md#message-feedback). |
64
64
65
65
The code snippet below demonstrates how to create a C2D message and send it to a device using [uAMQP library in Python](https://github.com/Azure/azure-uamqp-python).
66
66
@@ -122,11 +122,76 @@ As shown above, a C2D feedback message has content type of `application/vnd.micr
122
122
* Key `originalMessageId` in feedback body has the ID of the original C2D message sent by the service. This can be used to correlate feedback to C2D messages.
123
123
124
124
### Receive telemetry messages (service client)
125
+
By default, IoT Hub stores ingested device telemetry messages in a built-in Event hub. Your service client can use the AMQP protocol to receive the stored events.
126
+
127
+
For this purpose, the service client first needs to connect to the IoT Hub endpoint and receive a redirection address to the built-in Event Hubs. Service client then uses the provided address to connect to the built-in Event hub.
128
+
129
+
In each step, the client needs to present the following pieces of information:
130
+
* Valid service credentials (service SAS token).
131
+
* A well-formatted path to the consumer group partition it intends to retrieve messages from. For a given consumer group and partition ID, the path has the following format: `/messages/events/ConsumerGroups/<consumer_group>/Partitions/<partition_id>` (the default consumer group is `$Default`).
132
+
* An optional filtering predicate to designate a starting point in the partition (this can be in the form of a sequence number, offset or enqueued timestamp).
133
+
134
+
The code snippet below uses [uAMQP library in Python](https://github.com/Azure/azure-uamqp-python) to demonstrate the above steps.
135
+
136
+
```python
137
+
import json
138
+
import uamqp
139
+
import urllib
140
+
import time
141
+
142
+
# Use generate_sas_token implementation available here: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security#security-token-structure
For a given device ID, IoT Hub uses a hash of the device ID to determine which partition to store its messages in. The code snippet above demonstrates receiving events from a single such partition. Note, however, that a typical application often needs to retrieve events stored in all event hub partitions.
125
190
126
191
127
192
### Additional notes
128
193
* The AMQP connections may be disrupted due to network glitch, or expiry of the authentication token (generated in the code). The service client must handle these circumstances and re-establish the connection and links if needed. For the case of authentication token expiry, the client can also proactively renew the token prior to its expiry to avoid a connection drop.
129
-
* In some cases, your client must be able to correctly handle link redirections. Refer to your AMQP client documentation on how to do this.
194
+
* In some cases, your client must be able to correctly handle link redirections. Refer to your AMQP client documentation on how to handle this operation.
130
195
131
196
### Receive cloud-to-device messages (device and module client)
132
197
AMQP links used on the device side are as follows:
0 commit comments