Understanding Device Shadow Service in AWS IoT Core

   Go back to the Task List

  « 3. Update the shadow document    5. Delete the shadow document »

4. Get the shadow document

You will understand how to fetch device shadow document on demand in this task. The method remains the same where you use the reserved topics to get the device shadow.

  1. On the AWS IoT Core console, click on the Test menu. You see the MQTT Client which you can use to publish and subscribe to the topics.

    MQTT Client

  2. When you publish an empty message to the $aws/things/dojodevice1/shadow/get topic, AWS IoT core publishes the latest shadow document to the $aws/things/dojodevice1/shadow/get/accepted topic. If the get fails, a message is published to the $aws/things/dojodevice1/shadow/get/rejected topic.

  3. You first add subscriptions for $aws/things/dojodevice1/shadow/get/accepted and $aws/things/dojodevice1/shadow/get/rejected topics in the same way you did in the previous task.

    MQTT Client

    MQTT Client

  4. Next, publish empty message to the $aws/things/dojodevice1/shadow/get topic.

    MQTT Client

  5. The moment the message is published, you will see a green dot next to the $aws/things/dojodevice1/shadow/get/accepted topic. It indicates a new message published to this topic.

    MQTT Client

  6. Click on the $aws/things/dojodevice1/shadow/get/accepted topic to check the message. You can see the latest shadow document from the device and you can also see the delta which shows change over the previous shadow document of the device.

    MQTT Client

  7. The get operation is used by the device or IoT core to fetch the latest shadow document for the device. In the next step, you learn how to delete the shadow document.