Flush delay node by topic

Hi there,

I think it's beneficial to have an option to flush the delay node by topic instead of flushing all the messages at once.

For example, there could be devices sending requests in (via http in node) that need to wait for an operator's command. The operator send in a command that's saved in the flow's context and flush the delay node. Eventually the command is returned to the devices via http response.

Here without a per-topic flushing mechanism, it's impossible to commanding individual devices.

How many different topics do you need to handle?

Hi Remo,

Technically unbounded? You don't know how many devices you're going to add.

Is that a problem?

Hi there,

I just thought if it's a fixed and low number of devices/topics you could do something like this:

[{"id":"7e94e34ce121c251","type":"delay","z":"8df064aa6876a7dd","name":"queue A","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":720,"y":180,"wires":[["3245e1f09c733145"]]},{"id":"43bbd21e4100a711","type":"inject","z":"8df064aa6876a7dd","name":"input A","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"A","payloadType":"date","x":230,"y":140,"wires":[["23bd36c10fb74e21"]]},{"id":"d98ef494c681b977","type":"inject","z":"8df064aa6876a7dd","name":"input B","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"B","payloadType":"date","x":230,"y":180,"wires":[["23bd36c10fb74e21"]]},{"id":"c52a8d10191c610a","type":"inject","z":"8df064aa6876a7dd","name":"flush A","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"flush","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"A","payloadType":"date","x":230,"y":260,"wires":[["23bd36c10fb74e21"]]},{"id":"23bd36c10fb74e21","type":"switch","z":"8df064aa6876a7dd","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"A","vt":"str"},{"t":"eq","v":"B","vt":"str"},{"t":"eq","v":"C","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":490,"y":240,"wires":[["7e94e34ce121c251"],["82a313a9e294c98a"],["1bac31a3717d45f3"]]},{"id":"82a313a9e294c98a","type":"delay","z":"8df064aa6876a7dd","name":"queue B","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":720,"y":240,"wires":[["3245e1f09c733145"]]},{"id":"7dcb3c82da72efaf","type":"inject","z":"8df064aa6876a7dd","name":"flush B","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"flush","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"B","payloadType":"date","x":230,"y":300,"wires":[["23bd36c10fb74e21"]]},{"id":"3245e1f09c733145","type":"debug","z":"8df064aa6876a7dd","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":240,"wires":[]},{"id":"1bac31a3717d45f3","type":"delay","z":"8df064aa6876a7dd","name":"queue C","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":720,"y":300,"wires":[["3245e1f09c733145"]]},{"id":"b4327add7c20cb81","type":"inject","z":"8df064aa6876a7dd","name":"flush C","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"flush","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"C","payloadType":"date","x":230,"y":340,"wires":[["23bd36c10fb74e21"]]},{"id":"633ab4416171357b","type":"inject","z":"8df064aa6876a7dd","name":"input C","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"C","payloadType":"date","x":230,"y":220,"wires":[["23bd36c10fb74e21"]]}]

What happens if you run into a timeout? Have you checked out the q-gate node (node-red-contrib-queue-gate)?

Certainly an idea worth thinking about

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