If you choose to use a 'triggered flow', the easiest option is to use node-red-contrib-simple-message-queue and there is information in the node readme about the various options available.
This node is basically @dceejay's 'triggered flow' example wrapped up into a node, and works on the same principle.
If you want a simple flow to demonstrate it working, install the node-red-contrib-simple-message-queue
node (it's in the node-RED library), and then import the flow below.
Click the inject node and 5 messages will be injected into the flow, the first message will travel straight through the 'queue' node, and the remaining four will be queued, and released in sequence, as the preceding message acknowledges that it's been completed.
The delay node slows down the flow, so you can see what's happening, and simulates time taken to complete each action.
[
{
"id": "ca4b5b70.5a0678",
"type": "simple-queue",
"z": "c53060.842a0fa",
"name": "queue",
"firstMessageBypass": true,
"bypassInterval": "30000",
"x": 620,
"y": 790,
"wires": [
[
"ec60a83b.a96518"
]
]
},
{
"id": "ae67f50a.990b88",
"type": "change",
"z": "c53060.842a0fa",
"name": "release next msg",
"rules": [
{
"t": "set",
"p": "trigger",
"pt": "msg",
"to": "1",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 620,
"y": 720,
"wires": [
[
"ca4b5b70.5a0678"
]
]
},
{
"id": "ec60a83b.a96518",
"type": "delay",
"z": "c53060.842a0fa",
"name": "simulate delay in running function",
"pauseType": "delay",
"timeout": "3",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 850,
"y": 790,
"wires": [
[
"ae67f50a.990b88",
"3ecbc006.f8586"
]
]
},
{
"id": "8e3df100.38b86",
"type": "inject",
"z": "c53060.842a0fa",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 240,
"y": 790,
"wires": [
[
"b49e71eb.d2c9b"
]
]
},
{
"id": "3ecbc006.f8586",
"type": "debug",
"z": "c53060.842a0fa",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 940,
"y": 840,
"wires": []
},
{
"id": "b49e71eb.d2c9b",
"type": "function",
"z": "c53060.842a0fa",
"name": "Create some msg's",
"func": "var msg1 = { payload:\"first out of output\" };\nvar msg2 = { payload:\"second out of output\" };\nvar msg3 = { payload:\"third out of output\" };\nvar msg4 = { payload:\"fourth out of output\" };\nvar msg5 = { payload:\"fifth out of output\" };\nreturn [[ msg1, msg2, msg3, msg4, msg5 ]];",
"outputs": 2,
"noerr": 0,
"x": 430,
"y": 790,
"wires": [
[
"ca4b5b70.5a0678"
],
[]
]
}
]