use of org.graylog2.shared.messageq.MessageQueueException in project graylog2-server by Graylog2.
the class LocalKafkaMessageQueueWriter method write.
@Override
public void write(List<RawMessageEvent> entries) throws MessageQueueException {
final AtomicLong msgBytes = new AtomicLong(0);
final List<Journal.Entry> journalEntries = entries.stream().filter(Objects::nonNull).map(e -> new Journal.Entry(e.getMessageIdBytes(), e.getEncodedRawMessage())).peek(e -> msgBytes.addAndGet(e.getMessageBytes().length)).collect(Collectors.toList());
try {
writeToJournal(journalEntries);
} catch (Exception e) {
LOG.error("Unable to write to journal - retrying", e);
// Use retryer with exponential back-off to avoid spamming the logs.
try {
writeRetryer.call(() -> {
writeToJournal(journalEntries);
return null;
});
} catch (ExecutionException | RetryException ex) {
throw new MessageQueueException("Retryer exception", ex);
}
}
metrics.writtenMessages().mark(journalEntries.size());
metrics.writtenBytes().mark(msgBytes.get());
}
Aggregations