# Node red flow queuing

**URL:** <https://discourse.nodered.org/t/node-red-flow-queuing/78630>\
**Category:** General\
**Created:** [23 May 2023 10:40 UTC](https://discourse.nodered.org/t/node-red-flow-queuing/78630 "2023-05-23T10:40:30Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![nagaabhishek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nagaabhishek/32/78886_2.png) [@nagaabhishek](https://discourse.nodered.org/u/nagaabhishek)\
**Post date:** [23 May 2023 10:40 UTC](https://discourse.nodered.org/t/node-red-flow-queuing/78630/1 "2023-05-23T10:40:30Z")

</div>

Hi all,  
I have a nodered flow ona schedule basis using cron node. I need to queue the schedule till the previous flow execution is completed. Is there any way to do it

Thanks.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 May 2023 14:29 UTC](https://discourse.nodered.org/t/node-red-flow-queuing/78630/2 "2023-05-23T14:29:02Z")

</div>

Take a look at [node-red-contrib-queue-gate (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-queue-gate)

You could close the gate when the flow is executing and when it finishes send a message to the node to open the gate.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 May 2023 14:53 UTC](https://discourse.nodered.org/t/node-red-flow-queuing/78630/3 "2023-05-23T14:53:43Z")

</div>

This should do what you want. It uses a Delay node in Queuing mode to buffer them up and uses the Flush feature of that node to send the next one when the previous is complete. Select the Comment node, and in the Info tab in the right hand pane there will be additional instructions on how to use it. You replace the Function node with your nodes of course.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/6/5631a7d00e7be9fff05129be21473c25885d33e2.png)

```auto
[{"id":"b6630ded2db7d680","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":840,"wires":[["ed63ee4225312b40"]]},{"id":"ed63ee4225312b40","type":"delay","z":"bdd7be38.d3b55","name":"Queue","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":310,"y":840,"wires":[["d4d479e614e82a49","7eb760e019b512dc"]]},{"id":"a82c03c3d34f683c","type":"delay","z":"bdd7be38.d3b55","name":"Some more stuff to do","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":800,"y":840,"wires":[["7c6253e5d34769ac","b23cea1074943d4d"]]},{"id":"2128a855234c1016","type":"link in","z":"bdd7be38.d3b55","name":"link in 1","links":["7c6253e5d34769ac"],"x":95,"y":920,"wires":[["3a9faf0a95b4a9bb"]]},{"id":"7c6253e5d34769ac","type":"link out","z":"bdd7be38.d3b55","name":"link out 1","mode":"link","links":["2128a855234c1016"],"x":665,"y":920,"wires":[]},{"id":"b23cea1074943d4d","type":"debug","z":"bdd7be38.d3b55","name":"OUT","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":760,"wires":[]},{"id":"d4d479e614e82a49","type":"debug","z":"bdd7be38.d3b55","name":"IN","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":760,"wires":[]},{"id":"3a9faf0a95b4a9bb","type":"function","z":"bdd7be38.d3b55","name":"Flush","func":"return {flush: 1}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":190,"y":920,"wires":[["ed63ee4225312b40"]]},{"id":"7eb760e019b512dc","type":"function","z":"bdd7be38.d3b55","name":"Some functions to be performed","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":840,"wires":[["a82c03c3d34f683c"]]},{"id":"e35f37deeae94860","type":"comment","z":"bdd7be38.d3b55","name":"Set the queue timeout to larger than you ever expect the process to take","info":"OK, here is a simple flow which allows a sequence of nodes to be protected so that only one message is allowed in at a time. It uses a Delay node in Rate Limit mode to queue them, but releases them, using the Flush mechanism, as soon as the previous one is complete. Set the timeout in the delay node to a value greater than the maximum time you expect it ever to take. If for some reason the flow locks up (a message fails to indicate completion) then the next message will be released after that time.\nMake sure that you trap any errors and feed back to the Flush node when you have handled the error. Also make sure only one message is fed back for each one in, even in the case of errors.","x":270,"y":720,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![nagaabhishek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nagaabhishek/32/78886_2.png) [@nagaabhishek](https://discourse.nodered.org/u/nagaabhishek)\
**Post date:** [23 May 2023 16:09 UTC](https://discourse.nodered.org/t/node-red-flow-queuing/78630/4 "2023-05-23T16:09:50Z")

</div>

can u please give me a sample workflow

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 May 2023 18:06 UTC](https://discourse.nodered.org/t/node-red-flow-queuing/78630/5 "2023-05-23T18:06:46Z")

</div>

Instead of me writing you a sample flow, you should try yourself and show us what you accomplish and Then if it isn't working, provide your test flow and ask questions about it.

The best way to learn is by trial and error.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 May 2023 19:14 UTC](https://discourse.nodered.org/t/node-red-flow-queuing/78630/6 "2023-05-23T19:14:57Z")

</div>

And do try the flow I posted.

---

<div class="post-metadata">

**Author:** ![nagaabhishek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nagaabhishek/32/78886_2.png) [@nagaabhishek](https://discourse.nodered.org/u/nagaabhishek)\
**Post date:** [24 May 2023 10:21 UTC](https://discourse.nodered.org/t/node-red-flow-queuing/78630/7 "2023-05-24T10:21:05Z")

</div>

this mechanism is working, but providing delay for queuing is affecting the consecutive schedules

---

<div class="post-metadata">

**Author:** ![nagaabhishek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nagaabhishek/32/78886_2.png) [@nagaabhishek](https://discourse.nodered.org/u/nagaabhishek)\
**Post date:** [24 May 2023 10:27 UTC](https://discourse.nodered.org/t/node-red-flow-queuing/78630/8 "2023-05-24T10:27:08Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/5/d5cfa3ea52891bed4fe0a740c5d54cc059a81e36.png)  
For this approach the user message can be queued at schedules, but how to trigger it, the start process is triggering all queue messages at a time.

I want a scenario where the process has to run run one after the another

`[{"id":"9899bb48.7f52c","type":"q-gate","z":"e5c32195.7ce7b8","name":"q-gate","controlTopic":"control","defaultState":"queueing","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"peek","dropCmd":"drop","statusCmd":"status","maxQueueLength":"100","keepNewest":false,"qToggle":false,"persist":false,"x":330,"y":200,"wires":[["5f8f8bcb.2d05ac"]]},{"id":"590746c1.caebb","type":"debug","z":"e5c32195.7ce7b8","name":"output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":160,"wires":[]},{"id":"1c2bf5c0.966812","type":"inject","z":"e5c32195.7ce7b8","name":"inject messages","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":160,"wires":[["9899bb48.7f52c"]]},{"id":"61ff61a5.40e45","type":"inject","z":"e5c32195.7ce7b8","name":"start processing","topic":"control","payload":"peek","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":200,"wires":[["9899bb48.7f52c"]]},{"id":"5f8f8bcb.2d05ac","type":"delay","z":"e5c32195.7ce7b8","name":"process","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":460,"y":200,"wires":[["590746c1.caebb","d7383276.654278"]]},{"id":"10ce59bb.a439ae","type":"link out","z":"e5c32195.7ce7b8","name":"","links":["d702a195.4ac318"],"x":715,"y":240,"wires":[]},{"id":"d702a195.4ac318","type":"link in","z":"e5c32195.7ce7b8","name":"","links":["10ce59bb.a439ae"],"x":215,"y":240,"wires":[["9899bb48.7f52c"]]},{"id":"d7383276.654278","type":"function","z":"e5c32195.7ce7b8","name":"get next","func":"node.send({topic: \"control\", payload: \"drop\"})\nmsg.topic = \"control\"\nmsg.payload = \"peek\"\nreturn msg;","outputs":1,"noerr":0,"x":620,"y":200,"wires":[["10ce59bb.a439ae"]]}]`

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 May 2023 16:03 UTC](https://discourse.nodered.org/t/node-red-flow-queuing/78630/9 "2023-05-24T16:03:15Z")

</div>

> [@nagaabhishek](#):
>
> delay for queuing is affecting the consecutive schedules

The flow I posted will not add any delay.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 July 2023 16:03 UTC](https://discourse.nodered.org/t/node-red-flow-queuing/78630/10 "2023-07-23T16:03:51Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
