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
Copy file name to clipboardExpand all lines: articles/iot-hub/iot-hub-devguide-messages-c2d.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ ms.author: kgremban
7
7
ms.service: iot-hub
8
8
services: iot-hub
9
9
ms.topic: conceptual
10
-
ms.date: 03/15/2018
10
+
ms.date: 12/20/2022
11
11
ms.custom: mqtt, devx-track-azurecli
12
12
13
13
---
@@ -22,27 +22,27 @@ You send cloud-to-device messages through a service-facing endpoint, */messages/
22
22
23
23
To target each cloud-to-device message at a single device, your IoT hub sets the **to** property to */devices/{deviceId}/messages/devicebound*.
24
24
25
-
Each device queue holds, at most, 50 cloud-to-device messages. To try to send more messages to the same device results in an error.
25
+
Each device queue holds, at most, 50 cloud-to-device messages. An error occurs if you try to send more messages to the same device.
26
26
27
27
## The cloud-to-device message life cycle
28
28
29
29
To guarantee at-least-once message delivery, your IoT hub persists cloud-to-device messages in per-device queues. For the IoT hub to remove the messages from the queue, the devices must explicitly acknowledge *completion*. This approach guarantees resiliency against connectivity and device failures.
30
30
31
31
The life-cycle state graph is displayed in the following diagram:
32
32
33
-

33
+
:::image type="content" source="./media/iot-hub-devguide-messages-c2d/lifecycle.png" alt-text="Diagram showing the life-cycle state graph of cloud-to-device messages.":::
34
34
35
35
When the IoT hub service sends a message to a device, the service sets the message state to *Enqueued*. When a device wants to *receive* a message, the IoT hub *locks* the message by setting the state to *Invisible*. This state allows other threads on the device to start receiving other messages. When a device thread completes the processing of a message, it notifies the IoT hub by *completing* the message. The IoT hub then sets the state to *Completed*.
36
36
37
37
A device can also:
38
38
39
-
**Reject* the message, which causes the IoT hub to set it to the *Dead lettered* state. Devices that connect over the Message Queuing Telemetry Transport (MQTT) Protocol can't reject cloud-to-device messages.
39
+
**Reject* the message, which causes the IoT hub to set it to the *Dead lettered* state. Devices that connect over the Message Queuing Telemetry Transport (MQTT) protocol can't reject cloud-to-device messages.
40
40
41
-
**Abandon* the message, which causes the IoT hub to put the message back in the queue, with the state set to *Enqueued*. Devices that connect over the MQTT Protocol can't abandon cloud-to-device messages.
41
+
**Abandon* the message, which causes the IoT hub to put the message back in the queue, with the state set to *Enqueued*. Devices that connect over the MQTT protocol can't abandon cloud-to-device messages.
42
42
43
43
A thread could fail to process a message without notifying the IoT hub. In this case, messages automatically transition from the *Invisible* state back to the *Enqueued* state after a *visibility* time-out (or *lock* time-out). The value of this time-out is one minute and cannot be changed.
44
44
45
-
The **max delivery count** property on the IoT hub determines the maximum number of times a message can transition between the *Enqueued* and *Invisible* states. After that number of transitions, the IoT hub sets the state of the message to *Dead lettered*. Similarly, the IoT hub sets the state of a message to *Dead lettered* after its expiration time. For more information, see [Time to live](#message-expiration-time-to-live).
45
+
The **max delivery count** property on the IoT hub determines the maximum number of times a message can transition between the *Enqueued* and *Invisible* states. After that number of transitions, the IoT hub sets the state of the message to *Dead lettered*. Similarly, the IoT hub sets the state of a message to *Dead lettered* after its expiration time. For more information, see [Message expiration (time to live)](#message-expiration-time-to-live).
46
46
47
47
The [How to send cloud-to-device messages with IoT Hub](iot-hub-csharp-csharp-c2d.md) article shows you how to send cloud-to-device messages from the cloud and receive them on a device.
48
48
@@ -59,7 +59,7 @@ Every cloud-to-device message has an expiration time. This time is set by either
59
59
* The **ExpiryTimeUtc** property in the service
60
60
* The IoT hub, by using the default *time to live* that's specified as an IoT hub property
For more information, see[Cloud-to-device configuration options](#cloud-to-device-configuration-options).
63
63
64
64
A common way to take advantage of a message expiration and to avoid sending messages to disconnected devices is to set short *time to live* values. This approach achieves the same result as maintaining the device connection state, but it is more efficient. When you request message acknowledgments, the IoT hub notifies you which devices are:
65
65
@@ -72,12 +72,12 @@ When you send a cloud-to-device message, the service can request the delivery of
72
72
73
73
| Ack property value | Behavior |
74
74
| ------------ | -------- |
75
-
| none | The IoT hub doesn't generate a feedback message (default behavior). |
75
+
| none |Default. The IoT hub doesn't generate a feedback message. |
76
76
| positive | If the cloud-to-device message reaches the *Completed* state, the IoT hub generates a feedback message. |
77
77
| negative | If the cloud-to-device message reaches the *Dead lettered* state, the IoT hub generates a feedback message. |
78
78
| full | The IoT hub generates a feedback message in either case. |
79
79
80
-
If the **Ack** value is *full*, and you don't receive a feedback message, it means that the feedback message has expired. The service can't know what happened to the original message. In practice, a service should ensure that it can process the feedback before it expires. The maximum expiration time is two days, which leaves time to get the service running again if a failure occurs.
80
+
If the **Ack**property value is set to*full*, and you don't receive a feedback message, it means that the feedback message has expired. The service can't know what happened to the original message. In practice, a service should ensure that it can process the feedback before it expires. The maximum expiration time is two days, which leaves time to get the service running again if a failure occurs.
81
81
82
82
As explained in [Endpoints](iot-hub-devguide-endpoints.md), the IoT hub delivers feedback through a service-facing endpoint, */messages/servicebound/feedback*, as messages. The semantics for receiving feedback are the same as for cloud-to-device messages. Whenever possible, message feedback is batched in a single message, with the following format:
83
83
@@ -87,7 +87,7 @@ As explained in [Endpoints](iot-hub-devguide-endpoints.md), the IoT hub delivers
0 commit comments