use of org.graylog2.shared.buffers.RawMessageEvent 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());
}
use of org.graylog2.shared.buffers.RawMessageEvent in project graylog2-server by Graylog2.
the class DirectMessageHandler method onEvent.
@Override
public void onEvent(RawMessageEvent event) throws Exception {
final RawMessage rawMessage = event.getRawMessage();
processBuffer.insertBlocking(rawMessage);
if (rawMessage != null) {
processingStatusRecorder.updateIngestReceiveTime(rawMessage.getTimestamp());
}
// clear out for gc and to avoid promoting the raw message event to a tenured gen
event.clear();
}
Aggregations