Skip to content

Influx db java client batch does not write to DB #378

Open
@IdanFridman

Description

@IdanFridman

I am trying to write points to influxDB using their Java client.
Batch is important to me.

If I use the influxDB.enableBatch with influxDB.write(Point) no data is inserted.
If I use the BatchPoints and influxDB.write(batchPoints) - data is inserted successfully.

Both code samples are taken from: https://github.com/influxdata/influxdb-java/tree/influxdb-java-2.7

    InfluxDB influxDB = InfluxDBFactory.connect(influxUrl, influxUser, influxPassword);
    influxDB.setDatabase(dbName);
    influxDB.setRetentionPolicy("autogen");

    // Flush every 2000 Points, at least every 100ms
    influxDB.enableBatch(2000, 100, TimeUnit.MILLISECONDS);
    influxDB.write(Point.measurement("cpu")
            .time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
            .addField("idle", 90L)
            .addField("user", 9L)
            .addField("system", 1L)
            .build());

    Query query = new Query("SELECT idle FROM cpu", dbName);
    QueryResult result = influxDB.query(query);

Returns nothing.

    BatchPoints batchPoints = BatchPoints.database(dbName).tag("async", "true").build();
    Point point1 = Point
            .measurement("cpu")
            .tag("atag", "test")
            .addField("idle", 90L)
            .addField("usertime", 9L)
            .addField("system", 1L)
            .build();
    batchPoints.point(point1);
    influxDB.write(batchPoints);
    Query query = new Query("SELECT * FROM cpu ", dbName);
    QueryResult result = influxDB.query(query);

This returns data successfully.

As mentioned, I need the first way to function.
How can I achieve that?

versions:
influxdb-1.3.6
influxdb-java:2.7

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions