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

org.enodeframework.kafka.KafkaTool Maven / Gradle / Ivy

package org.enodeframework.kafka;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.enodeframework.queue.QueueMessage;

/**
 * @author [email protected]
 */
public class KafkaTool {

    public static QueueMessage covertToQueueMessage(ConsumerRecord record) {
        QueueMessage queueMessage = new QueueMessage();
        queueMessage.setBody(record.value());
        queueMessage.setTopic(record.topic());
        queueMessage.setRouteKey(record.key());
        return queueMessage;
    }

    public static ProducerRecord covertToProducerRecord(QueueMessage queueMessage) {
        return new ProducerRecord<>(queueMessage.getTopic(), queueMessage.getRouteKey(), queueMessage.getBody());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy