Processes the connectivity status of a downsteam node, saves data when it's down, passes it on when it's up, retreives and removes saved data when connection is restored
Node-RED node that processes the connectivity status of a downsteam node, saves data when it's down, passes it on when it's up, retreives and removes saved data when connection is restored.
Install from npm
npm install node-red-contrib-spool
This package contains one node tho pass input downstream or stores it depending on the downstream's node connectivity status. It needs an existing SQLite database to work.
Query node usage:
You will need to fill in the following fields:
- Path to a database file.
- Connected message format.
- Disconnected message format.
- (Optional) Custom name for the node.
- Create a flow that has the following nodes: an input node, a status node, Spool and an output node.
- Connect the input node and the status node to Spool.
- Connect Spool to the output node.
- Configure the status node to only detect changes of the output node connectivity status.
- Configure Spool according to the connection messages that the output node generates (3 required parameters must be set explicitly).
- Start passing inputs through the flow.
The following in the general logic of how Spool processes the inputs:
If current connection status is "Connected": 1.1 Pass the input message downstream 1.2 Retreive, pass downstream and remove any data that might be stored in the connected database previously
If the status is "Disconnected": 2.1 Don't pass the input data, store it in the connected database until the downstream node's connectivity restoration notice