Getting remainder of messages from "counting" batch node

Hello,

I'm working on a flow where I'm using "batch" to group a list of 1000+ requests to an API that can accept up to 200 data requests in one call.

For my application I want these to all come out at once. So, suppose my initial batch is of 1300 requests, I want six batches of 200, then a seventh batch of 100. I am using a split node, so the parts object provides enough constraint.

The below screenshot illustrates my problem. Here I am missing a final message of ["E"]

Flow export:

[{"id":"aebcc471.3fe5f8","type":"tab","label":"batch test","disabled":false,"info":""},{"id":"a28dbf30.e716a","type":"join","z":"aebcc471.3fe5f8","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":"false","timeout":"","count":"","reduceRight":false,"x":370,"y":140,"wires":[["fe72ad01.b839a"]]},{"id":"6eb2a691.8b2cf8","type":"split","z":"aebcc471.3fe5f8","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":330,"y":60,"wires":[["2439d888.102ab8"]]},{"id":"2439d888.102ab8","type":"batch","z":"aebcc471.3fe5f8","name":"batch by 2","mode":"count","count":"2","overlap":0,"interval":10,"allowEmptySequence":false,"topics":[],"x":370,"y":100,"wires":[["a28dbf30.e716a"]]},{"id":"5a901cf0.16cad4","type":"inject","z":"aebcc471.3fe5f8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"A\",\"B\",\"C\",\"D\",\"E\"]","payloadType":"json","x":150,"y":60,"wires":[["6eb2a691.8b2cf8"]]},{"id":"fe72ad01.b839a","type":"debug","z":"aebcc471.3fe5f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":140,"wires":[]},{"id":"ee8d3031.54bf","type":"inject","z":"aebcc471.3fe5f8","name":"reset test","props":[{"p":"reset","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":120,"y":100,"wires":[["2439d888.102ab8"]]}]

Msg.reset isn't accomplishing what I want.

Currently the only solution I can think of is to "spoof" the remainder of the batch, but this feels very inelegant.

I may just ditch the batch node and write a function instead.

Any ideas?

The split node can split on an array element count.
eg.

[{"id":"5a901cf0.16cad4","type":"inject","z":"aebcc471.3fe5f8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"A\",\"B\",\"C\",\"D\",\"E\"]","payloadType":"json","x":150,"y":60,"wires":[["6eb2a691.8b2cf8"]]},{"id":"6eb2a691.8b2cf8","type":"split","z":"aebcc471.3fe5f8","name":"","splt":"\\n","spltType":"str","arraySplt":"2","arraySpltType":"len","stream":false,"addname":"","x":330,"y":60,"wires":[["fe72ad01.b839a"]]},{"id":"fe72ad01.b839a","type":"debug","z":"aebcc471.3fe5f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":140,"wires":[]}]
1 Like

Excellent, thank you!

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