fluent-logger-java icon indicating copy to clipboard operation
fluent-logger-java copied to clipboard

Expose method to send multiple messages at once

Open wsorenson opened this issue 10 years ago • 3 comments

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

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

wsorenson avatar Apr 18 '14 12:04 wsorenson

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.

komamitsu avatar Apr 18 '14 15:04 komamitsu

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

wsorenson avatar Apr 18 '14 15:04 wsorenson

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

repeatedly avatar May 15 '15 10:05 repeatedly