Synchronized msg in flow , one by one

hello all,
I really newbie in node-red,
my question is ...
I got a flow that received event msg,
I want that every msg finish the flow and after a new msg start the flow.

tnx a lot ,

for example
msg start ---->msg finish then msg1 start ------> msg1 finish

You can use node-red-contrib-semaphore to ensure that only one message is allowed through at once. Depending on exactly what is in the flow there may be simpler ways. Can you give us an idea of what is there and why you need to do this?

hey Colin ,
tnx for answer so fast.
the reason that I need that is to avoid a collision in my flow variable's

You should not store per-message state in flow context. If there is a piece of state you want to associate with a message, you should set it as a property of the message as it passes through the flow. This would remove the restriction of having one message active in your flow at one time.

Here is a simple example showing how it can be done without using context

[{"id":"d6c7b712.a26a7","type":"inject","z":"5bb5a6a6.97527","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":413,"wires":[["d0f22ac1.1031b8"]]},{"id":"d0f22ac1.1031b8","type":"function","z":"5bb5a6a6.97527","name":"Save timestamp","func":"// save the data we want to keep in msg.savedData\nmsg.savedData = msg.payload\nmsg.payload  = \"some value\"\nreturn msg;","outputs":1,"noerr":0,"x":262,"y":414,"wires":[["70e6e940.498ae"]]},{"id":"70e6e940.498ae","type":"delay","z":"5bb5a6a6.97527","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":427,"y":413,"wires":[["3f17330b.ffe3e4"]]},{"id":"3f17330b.ffe3e4","type":"function","z":"5bb5a6a6.97527","name":"Pick it up again","func":"// pick up the saved value for use now\nmsg.payload = \"msg.savedData is \" + msg.savedData\nreturn msg;","outputs":1,"noerr":0,"x":603,"y":413,"wires":[["ae37c7da.33b8f"]]},{"id":"ae37c7da.33b8f","type":"debug","z":"5bb5a6a6.97527","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":577,"y":523,"wires":[]}]

Tnx a lot Colin , the issue fixed :slight_smile: