title: Node-RED: Combine / Join messages with the same ID into one message
body: <p><img src="https://i.stack.imgur.com/RbMQU.png" alt="Example Flow"></p>
  
  <p>We have this example flow in Node-RED. Incoming data is simulated via Trigger and "DoSomethin". We hava a username and a company name. For both we want to fecht the ID from a database. Here simulated by the Function "FetchUser" and "FetchCompany". Both returning an incrementing counter. Because in real world there may be multiple requests/triggers per second at a rate so fast that the database might not be fast enough to fetch the data before the next requests arrive. To simulate this I have a 2 seconds delay. Now when clicking the Trigger fast 5 times in a row, only one debug output is generated with user "5" and company "1", so 4 requests are lost. Since each trigger generates a unique message id it should be possible to join all corresponding messages and none should be lost. But how can that be achived? </p>
  
  <p>Exported Node-RED code for importing</p>
  
  <pre><code>[{"id":"f265141.b1fe4e8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"7cae48f.189e438","type":"inject","z":"f265141.b1fe4e8","name":"","topic":"","payload":"Trigger","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":340,"wires":[["8a2175a4.921"]]},{"id":"8a2175a4.921","type":"function","z":"f265141.b1fe4e8","name":"DataInputSimulation","func":"user=\"user@example.com\";\ncompany=\"ExampleCorp\";\nmsg.payload = {};\nmsg.payload.user = user;\nmsg.payload.company=company;\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":340,"wires":[["474672db.36bd14","6c146c08.d0e884"]]},{"id":"474672db.36bd14","type":"change","z":"f265141.b1fe4e8","name":"FetchUser","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.user","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"user","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":280,"wires":[["d7c10a91.8cf49"]]},{"id":"6c146c08.d0e884","type":"change","z":"f265141.b1fe4e8","name":"FetchCompany","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.company","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"company","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":380,"wires":[["6cd41950.b1f0b"]]},{"id":"d7c10a91.8cf49","type":"function","z":"f265141.b1fe4e8","name":"FetchUser","func":"if (typeof context.zaehler === 'undefined')\n{\n    context.zaehler=0;\n}\ncontext.zaehler++;\nmsg.payload = context.zaehler;\nmsg.parts = {};\nmsg.parts.id = msg._msgid;\nmsg.parts.index = 0;\nmsg.parts.count = 2;\nreturn msg;","outputs":1,"noerr":0,"x":830,"y":280,"wires":[["50504a67.e8a5c4","409aeeb4.586b28"]]},{"id":"6cd41950.b1f0b","type":"function","z":"f265141.b1fe4e8","name":"FetchCompany","func":"if (typeof context.zaehler === 'undefined')\n{\n    context.zaehler=0;\n}\ncontext.zaehler++;\nmsg.payload = context.zaehler;\nmsg.parts = {};\nmsg.parts.id = msg._msgid;\nmsg.parts.index = 1;\nmsg.parts.count = 2;\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":380,"wires":[["3f37bb6c.7c7484","955cad64.587d28"]]},{"id":"50504a67.e8a5c4","type":"debug","z":"f265141.b1fe4e8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1090,"y":280,"wires":[]},{"id":"3f37bb6c.7c7484","type":"debug","z":"f265141.b1fe4e8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1090,"y":380,"wires":[]},{"id":"409aeeb4.586b28","type":"join","z":"f265141.b1fe4e8","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":640,"y":580,"wires":[["c93fce1a.d3aa6"]]},{"id":"c93fce1a.d3aa6","type":"debug","z":"f265141.b1fe4e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":900,"y":600,"wires":[]},{"id":"955cad64.587d28","type":"delay","z":"f265141.b1fe4e8","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":840,"y":480,"wires":[["409aeeb4.586b28"]]}]
  </code></pre>
  
  <p>If manally set msg.parts.id and stuff like that, but it didn't help.</p>
  
  <p>Here as example the code of node FetchUser</p>
  
  <pre><code>if (typeof context.zaehler === 'undefined')
  {
      context.zaehler=0;
  }
  context.zaehler++;
  msg.payload = context.zaehler;
  msg.parts = {};
  msg.parts.id = msg._msgid;
  msg.parts.index = 0;
  msg.parts.count = 2;
  return msg;
  </code></pre>