fluent/fluent-logger-java

Expose method to send multiple messages at once

wsorenson opened this issue · 3 comments

message:
[tag, time, record]
or
[tag, [[time,record], [time,record], ...]]

For bulk writing, could we have a way to send the second?

There is no way to send multiple messages at once for now.

I think you want an API like this:

public class FluentLogger {
    public class Record {
        private final long timestamp;
        private final String key;
        private final Object val;

        public Record(long timestamp, String key, Object val) {
            this.timestamp = timestamp;
            this.key = key;
            this.val = val;
        }
    }

    public boolean multiLog(String tag, List<Record> records) {
           :
    }

I think this kind of multi sending has a difficulty related to error handling.

Let's consider the following case:

  1. you multi-send 100 records at once
  2. 20 records is sent well
  3. the connection between the Fluentd and logger gets wrong
  4. the logger buffers next 40 records in the memory
  5. the buffer gets full
  6. the logger returns false which means the buffer is full

When you know that the buffer is full , it's difficult to resend the unsent records without any duplication or lost of records for now.

Hmm, could it not combine all records into a single message which either succeeds/fails?

fluentd's in_forward can accept multiple events at once so
this method could be implemented: https://github.com/fluent/fluentd/blob/master/lib/fluent/plugin/in_forward.rb#L104-L113