Github user dlaboss commented on a diff in the pull request:

    https://github.com/apache/incubator-quarks/pull/67#discussion_r58390932
  
    --- Diff: 
samples/connectors/src/main/java/quarks/samples/connectors/iotf/IotfSensors.java
 ---
    @@ -109,6 +99,31 @@ public static void simulatedSensors(IotDevice device, 
boolean print) {
             // with event identifier "sensors".
             device.events(sensors, "sensors", QoS.FIRE_AND_FORGET);
         }
    +    
    +    /**
    +     * Create a heart beat device event with
    +     * identifier {@code heartbeat} to
    +     * ensure there is some immediate output and
    +     * the connection to IoTF happens as soon as possible.
    +     * @param device IoT device
    +     */
    +    public static void heartBeat(IotDevice device, boolean print) {
    --- End diff --
    
    I guess the comment could just add something like "If you are using an 
MQTT-based IotDevice, you may want to consider using the MQTT KeepAlive and 
LastWillAndTestament mechanisms instead of an explicit heartbeat."  ?
    
    It's true that this heartbeat provides a visible last-heartbeat-timestamp 
to clients.  However, a visible&reliable "I'm still connected" status seems to 
be possible using just the KA/LWT.  
    
    That HiveMQ reference suggests: with a "retained" LWT to a topic "status" 
with the value "offline", the device initially sends a *single* retained msg 
"online" to that topic.  Clients will see/receive "online" until the device is 
no longer connected, at which point they will receive "offline" (by virtue of 
the KA-induced LWT).  I think there's also an implied: upon graceful shutdown, 
the device sends a single retained "offline" to "status".
    
    Regardless, should an issue be created to discuss (or track) adding 
something to IotDevice for this higher level concept/feature, and to the 
MqttDevice and IotfDevice impls? Don't know if something like this is already 
part of the Watson IoT framework.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to