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.
-
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.
-
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.
-
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.
-
Next, publish empty message to the $aws/things/dojodevice1/shadow/get topic.
-
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.
-
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.
-
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.