Node.send(msg,false) and multiple outputs

Hi, I need to send messages asynchronously, within a function node, and with the second argument set as false. My problem is that I need to send two messages on two separate output, and for both of them using the cloneable setting as false.
For just one message on a single output it's ok node.send(msg,false). But what for two messages on two separate outputs?
Something like node.send([(msgA,false)],[(msgB,false)]).
I've tried several syntax but without success.



The false flag only applies to the first message passed to node.send.

If you need to send multiple messages, and ensure none of them is cloned, you'd have to make separate calls to node.send for each one...

node.send([msgA, null],false);
node.send([null, msgB],false);

Thanks so much

Sorry @knolleary, can you explain what happens if a message arrives to a function node while it's running? It will act as a queue, so it will be processed only after the ongoing code has been completed. Is that correct? Or, since we are speaking asynchronously, the new message starts to be processed and it can affect the variable already calculated by the former process?
Hope to have been clear

If the code in the function node has nothing asynchronous in it (so no waits for file access, no setTimeout() functions, or anything that causes the function to pause waiting for something) then a message cannot arrive at the input while the function is running (as node.js is single threaded). Nothing can happen till the function releases the processor.
However, if there are any asynchronous actions and a message arrives during the pause (or is already queued before the function starts) then the function node will start processing it immediately. No variables defined in the function will be overwritten though as each message gets a new set of variables. If you use context however then that will get updated by each execution of the function as it proceeds.

perfect, very clear.

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