All Downloads are FREE. Search and download functionalities are using the official Maven repository.

no.nav.common.kafka.consumer.util.TopicConsumerLogger Maven / Gradle / Ivy

package no.nav.common.kafka.consumer.util;

import no.nav.common.kafka.consumer.ConsumeStatus;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Listener which receives a consumed record and status from a {@link no.nav.common.kafka.consumer.TopicConsumer}
 * @param  topic key
 * @param  topic value
 */
public class TopicConsumerLogger implements TopicConsumerListener {

    private final Logger log = LoggerFactory.getLogger(this.getClass());

    @Override
    public void onConsumed(ConsumerRecord record, ConsumeStatus status) {
        if (status == ConsumeStatus.OK) {
            log.info("Consumed record topic={} partition={} offset={}", record.topic(), record.partition(), record.offset());
        } else {
            log.error("Failed to consume record topic={} partition={} offset={}", record.topic(), record.partition(), record.offset());
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy