---
title: "Batched Invocations"
url: https://docs.zeroc.com/ice/3.8/runtime/invocation/invocation-mode/batched-invocations
language: cpp
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# Batched Invocations

Programming language: C++. Other languages: [C#](https://docs.zeroc.com/ice/3.8/runtime/invocation/invocation-mode/batched-invocations/csharp.md), [Java](https://docs.zeroc.com/ice/3.8/runtime/invocation/invocation-mode/batched-invocations/java.md), [JavaScript](https://docs.zeroc.com/ice/3.8/runtime/invocation/invocation-mode/batched-invocations/js.md), [MATLAB](https://docs.zeroc.com/ice/3.8/runtime/invocation/invocation-mode/batched-invocations/matlab.md), [PHP](https://docs.zeroc.com/ice/3.8/runtime/invocation/invocation-mode/batched-invocations/php.md), [Python](https://docs.zeroc.com/ice/3.8/runtime/invocation/invocation-mode/batched-invocations/python.md), [Ruby](https://docs.zeroc.com/ice/3.8/runtime/invocation/invocation-mode/batched-invocations/ruby.md), [Swift](https://docs.zeroc.com/ice/3.8/runtime/invocation/invocation-mode/batched-invocations/swift.md).

A batched invocation is an invocation made with a batch proxy, a proxy whose [invocation mode](https://docs.zeroc.com/ice/3.8/runtime/invocation/invocation-mode.md) is batch oneway or batch datagram. It queues the request on the client side instead of sending it. Flushing the queue sends all the queued requests in a single message, which saves the per-request overhead when a client sends many small requests.

You get a batch proxy from `ice_batchOneway` or `ice_batchDatagram`, and `ice_flushBatchRequests` flushes its queue:

```cpp
WeatherStationPrx batch = weatherStation.ice_batchOneway();
batch.report(sensorId, timeStamp1, reading1);
batch.report(sensorId, timeStamp2, reading2);
batch.ice_flushBatchRequests();
```

A batch travels as a single message, so the object adapter receives either all the requests of the batch or none. Ice dispatches the requests of a batch one after the other, in the order in which they were written into the batch. With synchronous dispatch, the server therefore processes these requests in order. With asynchronous dispatch, Ice starts the next dispatch as soon as the dispatch method returns, which can be before the previous request is fully processed.

Each batch proxy has its own queue, even when several proxies refer to the same Ice object, and the requests it queued are lost if the application releases the proxy before flushing them. Ice does not [retry](https://docs.zeroc.com/ice/3.8/runtime/invocation/automatic-retries/cpp.md) a flush: if the connection fails while Ice sends the batch, its requests are lost.

## Automatic Flushing

Ice flushes a batch automatically when a new request makes it reach the size set by [Ice.BatchAutoFlushSize](https://docs.zeroc.com/ice/3.8/property-reference/ice-properties/cpp.md#ice.batchautoflushsize), in KiB: Ice sends the requests queued before this one and starts a new batch with it. The default is 1024 KiB (1 MiB), and `0` disables automatic flushing for batch oneway invocations. Keep this size at or below the receiver's `Ice.MessageSizeMax`, the largest message the receiver accepts.

For batch datagram invocations, Ice caps this size at [Ice.UDP.SndSize](https://docs.zeroc.com/ice/3.8/property-reference/ice-udp-properties/cpp.md#ice.udp.sndsize) bytes, or 65,507 bytes when that property is not set, including when `Ice.BatchAutoFlushSize` is `0`.

To flush with your own policy, install a [batch invocation interceptor](https://docs.zeroc.com/ice/3.8/runtime/invocation/invocation-mode/batched-invocation-interceptors/cpp.md).

## Batched Invocations for Fixed Proxies

A batch [fixed proxy](https://docs.zeroc.com/ice/3.8/runtime/invocation/creating-proxies/cpp.md#creating-a-proxy-from-a-connection) queues its requests in the queue of its connection, which all the batch fixed proxies that use this connection share. `ice_flushBatchRequests` on a fixed proxy flushes this queue, as does `flushBatchRequests` on the connection; `flushBatchRequests` on a communicator flushes the queues of all its connections. None of these flush the queue of a regular proxy. This holds for both batch modes: a batch datagram fixed proxy uses a UDP connection, and a batch oneway fixed proxy uses a connection of another transport.
