How to enable batch mode in Java for InfluxDB 2.0?

The 1.8 version allows me to enable batching of single Point writes as easy as follows:

influxDB.enableBatch(100000, 10000, TimeUnit.MILLISECONDS);

Could you tell me what is the equivalent of 2.0 version to enable batch mode? It would be better if you could give me a Java code snippet.

Hi @mfrice,

thanks for using our client. The default configuration for WriteApi is asynchronous batching mode. For more info see - influxdb-client-java/client at master · influxdata/influxdb-client-java · GitHub


Hi @bednar ,

Thank you for your reply! The documentation didn’t show how to modify the batch options. I tried to write my own code, which is as follows:

WriteApi writeApi = client.makeWriteApi(

Then I call its writePoint(Point point) method as usual.


Is it correct? Is it the same as influxDB.enableBatch(300000, 30000, TimeUnit.MILLISECONDS); then call influxDB.write(point) as in the older version?

Here is an example: influxdb-client-java/ at 050db6ae578951a097c4525bee6c36d83c61f953 · influxdata/influxdb-client-java · GitHub

Yes, but be sure that you use WriteApi as a singleton and also call .close() after finish your work.


Hi @bednar ,
I am really confused that I keep getting the bufferLimit warning which I’ve never gotten in the older version.

Aug 24, 2021 4:02:05 AM logEvent
WARNING: Backpressure applied, try increase WriteOptions.bufferLimit

I tried several configurations including default but still get it. Do I need to manually clear the buffer before restart my program?

On the other hand, does the backpressure strategy means I would loss data? Can I choose to NOT loss data when the buffer is full?

update: I found there is a WriteApiBlocking class, does it also support batching on default?

No. Increase the bufferLimit because the default value is 10_000. You can use something like:


Before restart your program, you should call: writeApi.close(); to flush your data into InfluxDB.

You are able to choose from following strategies:

  • DROP_OLDEST - Drop the oldest data points from the backlog
  • DROP_LATEST - Drop the latest data points from the backlog
  • ERROR - Signal a exception

For more info see - influxdb-client-java/ at master · influxdata/influxdb-client-java · GitHub