Queues up elements until either a duration of time has passed or any threshold in a given set of
thresholds is breached, and then delivers the elements in a batch to the consumer.
Adds an element to the batcher. If the element causes the collection to go past any of the
thresholds, the batch will be sent to theThresholdBatchReceiver.
Push the current batch to the batch receiver. Returns an ApiFuture that completes once the
batch has been processed by the batch receiver and the flow controller resources have been
released.
Note that this future can complete for the current batch before previous batches have
completed, so it cannot be depended upon for flushing.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis page details the \u003ccode\u003eThresholdBatcher\u003c/code\u003e class in version 2.50.0 of the Java API, which is used to queue elements until time or threshold criteria are met.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eThresholdBatcher\u003c/code\u003e class, extending \u003ccode\u003ejava.lang.Object\u003c/code\u003e, delivers elements in batches to a consumer once thresholds are reached.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003enewBuilder()\u003c/code\u003e static method allows you to get a new builder for configuring a \u003ccode\u003eThresholdBatcher\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eElements can be added to the batcher using the \u003ccode\u003eadd(E e)\u003c/code\u003e method, potentially triggering a batch delivery if thresholds are exceeded.\u003c/p\u003e\n"],["\u003cp\u003eThe method \u003ccode\u003epushCurrentBatch()\u003c/code\u003e allows for the manual sending of the current batch to the batch receiver and returns an ApiFuture indicating when the flow controller resources are released.\u003c/p\u003e\n"]]],[],null,[]]