Send placeholder messages when a stream stops sending


You have a stream of messages coming from a sensor at regular intervals. If the sensor stops sending messages, you want to send placeholder messages at the same rate.

For example, the sensor data may be feeding a Dashboard chart. If the sensor stops sending, the chart will stop updating. So placeholder messages are needed for the chart to update with a 0 value to highlight the sensor has stopped.


Use the Trigger node to detect when a message has not arrived after a defined interval and a second Trigger node to send the placeholder messages at a regular interval.




In the example flow, the top branch represents the normal flow of the messages, from the Inject node to the Debug node.

The messages also get passed to the first Trigger node on a second branch of the flow. That node is configured to initially send a payload of "reset", then to wait for 2 seconds before sending a timeout message. The option to extend the delay if new messages arrive is also selected. This means as long as messages continue to arrive, the node will not do anything. Once 2 seconds passes after the last message to arrive, it will send on the timeout message.

The timeout message feeds into a second Trigger node. This node is configured to send on 0 every two seconds and feeds back into the top branch. The node is also configured to stop sending if it receives a msg.payload of "reset". As this is the initial message sent by the first Trigger node when it receives a sensor message, this will cause the second Trigger node to be reset when the sensor resumes sending its own messages.