Join Sequence Recipe

control the order in which messages are joined.

Solution

Attach msg.parts to your messages to control the order in which they are auto-assembled by the join node...

Discussion

  • msg.parts.group must be identical for all parts
  • msg.parts.count is the number of packages that will be joined
  • msg.parts.index should be in {0 .. msg.parts.count - 1}

Note:

  • missing parts (missing index) will be replaced with null objects
  • duplicate parts (same index) will be overridden
[{"id":"b0d0bf45.3b9c6","type":"change","z":"8e046e9.da7d29","name":"parts.index = 1","rules":[{"t":"set","p":"parts.index","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":220,"wires":[["66ee9fcf.ec9cc"]]},{"id":"d1af64ea.236868","type":"join","z":"8e046e9.da7d29","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":910,"y":220,"wires":[["f148be71.f09278"]]},{"id":"6ec1c3ab.008bd4","type":"change","z":"8e046e9.da7d29","name":"parts.index = 0","rules":[{"t":"set","p":"parts.index","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":120,"wires":[["66ee9fcf.ec9cc"]]},{"id":"a39825e3.e01b9","type":"change","z":"8e046e9.da7d29","name":"parts.index = 2","rules":[{"t":"set","p":"parts.index","pt":"msg","to":"2","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":320,"wires":[["66ee9fcf.ec9cc"]]},{"id":"f148be71.f09278","type":"debug","z":"8e046e9.da7d29","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1070,"y":220,"wires":[]},{"id":"66ee9fcf.ec9cc","type":"change","z":"8e046e9.da7d29","name":"group id and count","rules":[{"t":"set","p":"parts.id","pt":"msg","to":"mygroup","tot":"str"},{"t":"set","p":"parts.count","pt":"msg","to":"3","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":220,"wires":[["d1af64ea.236868"]]},{"id":"2e221b1.51df8e4","type":"inject","z":"8e046e9.da7d29","name":"","topic":"","payload":"Mary","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":100,"wires":[["6ec1c3ab.008bd4"]]},{"id":"10bd8f79.53bee9","type":"inject","z":"8e046e9.da7d29","name":"","topic":"","payload":"Bob","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":140,"wires":[["6ec1c3ab.008bd4"]]},{"id":"1e097073.0d1fb","type":"inject","z":"8e046e9.da7d29","name":"","topic":"","payload":"likes","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":200,"wires":[["b0d0bf45.3b9c6"]]},{"id":"f4198579.6348b8","type":"inject","z":"8e046e9.da7d29","name":"","topic":"","payload":"hates","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":240,"wires":[["b0d0bf45.3b9c6"]]},{"id":"8e0e22e9.cfa61","type":"inject","z":"8e046e9.da7d29","name":"","topic":"","payload":"Summer","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":300,"wires":[["a39825e3.e01b9"]]},{"id":"93dfd24.5cc25b","type":"inject","z":"8e046e9.da7d29","name":"","topic":"","payload":"Winter","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":340,"wires":[["a39825e3.e01b9"]]}]

Flow Info

Created 4 years, 2 months ago
Rating: 3.6666666666666665 3

Owner

Actions

Rate:

Node Types

Core
  • change (x4)
  • debug (x1)
  • inject (x6)
  • join (x1)

Tags

  • cookbook
  • flowcontrol
  • join
  • sequence
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option