# Getting remainder of messages from "counting" batch node

**URL:** <https://discourse.nodered.org/t/getting-remainder-of-messages-from-counting-batch-node/48728>\
**Category:** General\
**Created:** [21 July 2021 18:00 UTC](https://discourse.nodered.org/t/getting-remainder-of-messages-from-counting-batch-node/48728 "2021-07-21T18:00:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdkrieg](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mdkrieg/32/39091_2.png) [@mdkrieg](https://discourse.nodered.org/u/mdkrieg)\
**Post date:** [21 July 2021 18:00 UTC](https://discourse.nodered.org/t/getting-remainder-of-messages-from-counting-batch-node/48728/1 "2021-07-21T18:00:46Z")

</div>

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"]

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/a/5a15f44ce2a17d3aa80c774933162f616a13d6fa.png)

Flow export:

```auto
[{"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?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [21 July 2021 18:40 UTC](https://discourse.nodered.org/t/getting-remainder-of-messages-from-counting-batch-node/48728/2 "2021-07-21T18:40:48Z")

</div>

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

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![mdkrieg](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mdkrieg/32/39091_2.png) [@mdkrieg](https://discourse.nodered.org/u/mdkrieg)\
**Post date:** [21 July 2021 18:54 UTC](https://discourse.nodered.org/t/getting-remainder-of-messages-from-counting-batch-node/48728/3 "2021-07-21T18:54:58Z")

</div>

Excellent, thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 August 2021 18:55 UTC](https://discourse.nodered.org/t/getting-remainder-of-messages-from-counting-batch-node/48728/4 "2021-08-04T18:55:03Z")

</div>

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