io.strimzi.kafka.bridge.converter.MessageConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kafka-bridge Show documentation
Show all versions of kafka-bridge Show documentation
Bridge that allows HTTP clients to interact with Apache Kafka clusters.
The newest version!
/*
* Copyright Strimzi authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.strimzi.kafka.bridge.converter;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.producer.ProducerRecord;
import java.util.List;
/**
* Interface for a message converter between Kafka record and bridge message
*/
public interface MessageConverter {
/**
* Converts a message to a Kafka record
*
* @param kafkaTopic Kafka topic for sending message
* @param partition partition of topic where the messages are sent when partition is specified in the request
* @param message message to convert
* @return Kafka record
*/
ProducerRecord toKafkaRecord(String kafkaTopic, Integer partition, M message);
/**
* Convert a collection of messages to Kafka records
*
* @param kafkaTopic Kafka topic for sending message
* @param partition partition of topic where the messages are sent when partition is specified in the request
* @param messages collection of messages to convert
* @return Kafka records
*/
List> toKafkaRecords(String kafkaTopic, Integer partition, C messages);
/**
* Converts a Kafka record to a message
*
* @param address address for sending message
* @param record Kafka record to convert
* @return message
*/
M toMessage(String address, ConsumerRecord record);
/**
* Converts Kafka records to a collection of messages
*
* @param records Kafka records to convert
* @return a collection of messages
*/
C toMessages(ConsumerRecords records);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy