A simple queue node that store incoming messages in memory queue and uses a feedback from a following action or trigger message to release the next message stored in the queue.
npm install node-red-contrib-simple-message-queuenode-red-contrib-simple-message-queue
================================



A simple queue node that store incoming messages in memory queue and uses a feedback from a following action or trigger message to release the next message stored in the queue.
reset: If a message is received with the reset property, all messages in the queue will be cleared. In addition, the node will not forward the incoming reset message for processing by any subsequent nodes in the sequence.
ttl: If a message is received with this property, a message will be added to the queue and will live in the queue for specific value in milliseconds. The value of the TTL must be a non-negative integer (0 <= n), describing the TTL period in milliseconds. Thus a value of 1000 means that a message added to the queue will live in the queue for 1 second. If message with TTL property has not been released for specified time, it will be deleted from queue without any output.
queueCount: If a message is received with this property, node will send message with number of messages left in the queue in _queueCount property. This message won't store in queue.
peek: If a message is received with this property, the node will send a copy of the next message in the queue without removing it from the queue. The outbound message will have a _queueCount property with number of messages left in the queue, a _isPeek property set to true, and a _triggerSource property set to "peek" to distinguish it from triggered messages. This operation does not trigger status nodes. This message won't be stored in the queue.
bypass: If a message is received with this property, and it set to true, bypass mode will turned on and all new incoming messages will be bypassed to output with _queueCount property, messaged in queue will not be cleared. If bypass property set to false, bypass mode will turned off and node return to normal operational, queue will not be cleared. Message with bypass property won't store in queue and trigger any messages.
bypassInterval: Message with this property allow to dynamically change bypass interval in milliseconds from config, 0 - no bypass.
_queueCount: Number of messages remaining in the queue after this message was released.
_triggerSource: A string indicating how the message was released. Possible values:
- "trigger" - Message was released by an explicit trigger command
- "bypassInterval" - Message was released automatically by the bypass interval timer
- "bypass" - Message was sent directly because bypass mode is enabled
- "firstMessage" - Message was sent as the first message bypass
- "peek" - Message was retrieved using peek (also includes _isPeek: true)
These properties allow you to differentiate and handle messages differently based on how they were released in your Node-RED flows.
Bypass interval: If this value greater than 0, node will realease message from queue without trigger after specific interval in milliseconds since last message send.
This node is based on https://gist.github.com/dceejay/cea8afa28b7a93ebdc0f - respect to @dceejay (Dave Conway-Jones) https://github.com/dceejay
[{"id":"e089622.6a906a","type":"tab","label":"Flow 1"},{"id":"fe09fb63.f859e8","type":"inject","z":"e089622.6a906a","name":"","topic":"","payload":"test","payloadType":"str","repeat":"","crontab":"","once":false,"x":250,"y":160,"wires":[["6c1851d1.8b28f"]]},{"id":"cdb38d47.cd149","type":"debug","z":"e089622.6a906a","name":"","active":true,"console":"false","complete":"true","x":870,"y":160,"wires":[]},{"id":"4b9c998a.373cc8","type":"inject","z":"e089622.6a906a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":240,"y":260,"wires":[["eda764e1.8074b8"]]},{"id":"eda764e1.8074b8","type":"change","z":"e089622.6a906a","name":"","rules":[{"t":"set","p":"trigger","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":260,"wires":[["6c1851d1.8b28f"]]},{"id":"c5d04e3b.efe1f","type":"inject","z":"e089622.6a906a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":240,"y":320,"wires":[["4f231841.69dd78"]]},{"id":"4f231841.69dd78","type":"change","z":"e089622.6a906a","name":"Bypass set to true","rules":[{"t":"set","p":"bypass","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":320,"wires":[["6c1851d1.8b28f"]]},{"id":"49783823.727dd8","type":"inject","z":"e089622.6a906a","name":"","topic":"","payload":"test","payloadType":"str","repeat":"","crontab":"","once":false,"x":250,"y":120,"wires":[["b6103616.738bb8"]]},{"id":"b6103616.738bb8","type":"change","z":"e089622.6a906a","name":"","rules":[{"t":"set","p":"ttl","pt":"msg","to":"2000","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":120,"wires":[["6c1851d1.8b28f"]]},{"id":"61c94eb4.f285e","type":"inject","z":"e089622.6a906a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":240,"y":360,"wires":[["f80b3fd.988a6c"]]},{"id":"f80b3fd.988a6c","type":"change","z":"e089622.6a906a","name":"Bypass set to false","rules":[{"t":"set","p":"bypass","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":360,"wires":[["6c1851d1.8b28f"]]},{"id":"86543cdf.3706c","type":"inject","z":"e089622.6a906a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":240,"y":220,"wires":[["6d3ba29e.ea192c"]]},{"id":"6d3ba29e.ea192c","type":"change","z":"e089622.6a906a","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":220,"wires":[["6c1851d1.8b28f"]]},{"id":"5190f4e7.cabbbc","type":"inject","z":"e089622.6a906a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":240,"y":80,"wires":[["61d34c47.cdfc94"]]},{"id":"61d34c47.cdfc94","type":"change","z":"e089622.6a906a","name":"","rules":[{"t":"set","p":"queueCount","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":80,"wires":[["6c1851d1.8b28f"]]},{"id":"6c1851d1.8b28f","type":"simple-queue","z":"e089622.6a906a","name":"","firstMessageBypass":false,"bypassInterval":"0","x":690,"y":160,"wires":[["cdb38d47.cd149"]]}]