[ANNOUNCE] node-red-contrib-queue-gate

A new node, node-red-contrib-queue-gate, has been uploaded to npm. This is an enhanced version of node-red-contrib-simple-gate that additionally allows messages to be queued and released at a later time. See the discussion at Gate node using Blockly.

From the help text:
The node will transmit the input message to its output when in the open state and block it when closed. In the queueing state, the input message is added to the end of the message queue, provided space is available. The user can limit the size of the queue to prevent memory problems. Messages in the queue can be released (in the order received) either singly or the entire queue at once.

Messages with the user-defined topic Control Topic (set when the node is deployed) are not passed through but are used to control the state of the gate or the queue.

Control messages can have values representing commands that change the state of the gate: open, close, toggle, queue, or default. Messages that control the queue are trigger, flush and purge. The (case-insensitive) strings representing these commands are set by the user when the node is deployed. If a control message is received but not recognized, there is no output or change of state, and the node reports an error.

When first deployed or after a default command, the gate is in the user-selected state defined by Default State.

The node can be downloaded from npm, GitHub, or the palette manager.

2 Likes

this sounds very thorough ! :+1:

1 Like

It would be helpful if you could add your git repo URL to the 'repository' field name in your package.json file, so users can see in more detail how the node works.

2 Likes

I realized there was a problem but didn't know how to solve it. Thanks for the help. This is my first go at using GitHub and npm, so there are bound to be glitches. Please keep pointing them out.

2 Likes

Giving this a try out in queue mode - all well so far

Minor feedback - the node is labelled q gate but help text says q-gate - pick one and stick with it :slight_smile:

Also flush and purge are too similar in meaning - maybe change flush to something like release?

(For the delay node we use reset and flush)

Good catch. It's supposed to have the hyphen. I'll fix it.

I'm with @dceejay on this. "Flush" is pretty standard for mail and other other queues. "Delete" sounds a bit strong, so "reset" works for me. It will be a couple of days before I can update.

Strange. I'm not finding any problem in the html file. Is it possible that the editor is doing something to the name, perhaps the way it strips out -in and -out from node names?

OK - flush and reset :slight_smile:

This oddity will be resolved in version 1.0.1 by adding
paletteLabel: "q–gate"
to the html file. HOWEVER, the character in this palletLabel that appears to be a hyphen is actually Unicode U+2013 (en dash) not Unicode: U+002D (hyphen-minus). Using U+002D in palletLabel also causes the hyphen to disappear in the palette, tending to confirm my suspicion that the editor is responsible.

1 Like

I want to use this in a flow but having trouble getting it to queue.

Should it default to automatically queuing messages when closed and then let them all through when the gate is opened?

This isn't working for me

image

[{"id":"43e9ec54.e1dfd4","type":"debug","z":"4fc7465b.4a9d28","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1200,"y":720,"wires":[]},{"id":"3c9e2a90.0dada6","type":"q-gate","z":"4fc7465b.4a9d28","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","maxQueueLength":"100","keepNewest":false,"x":1010,"y":720,"wires":[["43e9ec54.e1dfd4"]]},{"id":"d774a5f7.d20b38","type":"inject","z":"4fc7465b.4a9d28","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":800,"y":720,"wires":[["3c9e2a90.0dada6"]]},{"id":"d7a7ba22.030d78","type":"inject","z":"4fc7465b.4a9d28","name":"","topic":"control","payload":"toggle","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":810,"y":760,"wires":[["3c9e2a90.0dada6"]]}]

To quote from teh info tab for the node
"Transmits the input message when in the open state, blocks it when closed , and adds it to the message queue when in the queueing state".
You are toggling between Open and Closed. I think you want to switch between Open and Queuing rather than Closed (which discards messages).

Well that what seems to be happening :slight_smile:

And its what the simple gate node does

I'm sure I did mange to do this in the past but how to do it now is eluding me

The toggle switches between open and closed, you need to switch between open and queuing, as described in the info tab.

[{"id":"2d8fd1e0.23158e","type":"debug","z":"514a90a5.c7bae8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":524,"y":538,"wires":[]},{"id":"44dbf6d3.4edfe","type":"q-gate","z":"514a90a5.c7bae8","name":"","controlTopic":"control","defaultState":"queueing","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","maxQueueLength":"100","keepNewest":false,"x":350,"y":538,"wires":[["2d8fd1e0.23158e"]]},{"id":"c76cf295.0ed428","type":"inject","z":"514a90a5.c7bae8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":538,"wires":[["44dbf6d3.4edfe"]]},{"id":"a7ca71cf.4d60a","type":"inject","z":"514a90a5.c7bae8","name":"","topic":"control","payload":"queue","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":578,"wires":[["44dbf6d3.4edfe"]]},{"id":"d940a95b.428c","type":"inject","z":"514a90a5.c7bae8","name":"","topic":"control","payload":"open","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":149,"y":623,"wires":[["44dbf6d3.4edfe"]]}]

Got you now - ta

I'm glad this is sorted. Currently, the only toggle command available switches back and forth between open and closed states. At one time, I considered toggle commands involving the queueing state, but gave up the idea. The node could handle it internally, but the control message structure and user interface quickly became too fussy. Given a clear requirement, I could be convinced to take another look.

I'm thinking simple selection in the config - do want toggle to select between open/closed or open/queued

Got it. I will take another look. Please raise an issue on GitHub, so we can continue the discussion there. I'm leaving tomorrow on a two-week holiday, so you probably won't see much from me soon, except perhaps the sketch of a proposal. Please consider whether when the gate switches from queueing to closed the queue should be flushed (all messages forwarded at once) or reset (all messages deleted).

(Jumping in) I would say reset/dropped. If you want to deliver them you could go. Queued - open - closed