How to know when a flow is done with multiple queued messages?

Every day, my flow fetches a variable amount of orders from a database that is to be processed.

One day it may be 10 orders, the next day it may be 55 orders. It varies from day to day.

I have a delay node that rate limits, so that only one message (order) can pass every 10 seconds.

What I want to achieve is to call another flow (or pass through a message to further continue the flow in another "branch") only when the last order of the day is processed, in other words when the last message in the queue has been processed. For example to send me an email that says "All orders are done for the day" or something similar. If I wire in my email node at the end of the flow, I get an email every time an order is processed which is not what I want. Only when the last one is done.

But when the number of messages/orders is different each day, how can I achieve this?

A trigger node can do that.

  • Send nothing
  • Wait for 30 seconds
  • Extend delay if new message arrives
  • Then send "Finished"

You can monitor the count on the delay node with a status node it will show text "0" when last message sent, it will send text "0" again when the rate delay for last message elapses also. So last message should be clear after a join of 2 text "0" messages
e.g.

[{"id":"47598da78b252656","type":"switch","z":"d1395164b4eec73e","name":"","property":"status.text","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":590,"y":160,"wires":[["534613a0bcede03a"]]},{"id":"14e67ff4e0591ac4","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2,3,4,5,6]","payloadType":"json","x":340,"y":80,"wires":[["87f3c51d75911aa1"]]},{"id":"87f3c51d75911aa1","type":"split","z":"d1395164b4eec73e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":490,"y":80,"wires":[["73bedc964e09ee0e"]]},{"id":"73bedc964e09ee0e","type":"delay","z":"d1395164b4eec73e","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":660,"y":80,"wires":[["59cf2fed68dcfb85"]]},{"id":"59cf2fed68dcfb85","type":"debug","z":"d1395164b4eec73e","name":"debug 2566","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":80,"wires":[]},{"id":"521a5c69d8a3c0ba","type":"status","z":"d1395164b4eec73e","name":"","scope":["73bedc964e09ee0e"],"x":420,"y":160,"wires":[["47598da78b252656"]]},{"id":"534613a0bcede03a","type":"join","z":"d1395164b4eec73e","name":"","mode":"custom","build":"array","property":"status","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":710,"y":160,"wires":[["1222d16c4a76506f"]]},{"id":"1222d16c4a76506f","type":"debug","z":"d1395164b4eec73e","name":"debug 2567","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":870,"y":160,"wires":[]}]

So simple, thank you! It works perfectly for my use case.

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