dev.snowdrop.vertx.sample.kafka.KafkaLogger Maven / Gradle / Ivy
package dev.snowdrop.vertx.sample.kafka;
import dev.snowdrop.vertx.kafka.KafkaProducer;
import dev.snowdrop.vertx.kafka.ProducerRecord;
import reactor.core.publisher.Mono;
import static dev.snowdrop.vertx.sample.kafka.KafkaSampleApplication.LOG_TOPIC;
final class KafkaLogger {
private final KafkaProducer producer;
KafkaLogger(KafkaProducer producer) {
this.producer = producer;
}
public Mono logMessage(String body) {
// Generic key and value types can be inferred if both key and value are used to create a builder
ProducerRecord record = ProducerRecord.builder(LOG_TOPIC, body).build();
return producer.send(record)
.log("Kafka logger producer")
.then();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy