net.mguenther.kafka.junit.RecordProducer Maven / Gradle / Ivy
package net.mguenther.kafka.junit;
import org.apache.kafka.clients.producer.RecordMetadata;
import java.util.List;
/**
* Provides the means to send key-value pairs or un-keyed values to a Kafka topic. The send
* operations a {@code RecordProducer} provides are synchronous in their nature.
*/
public interface RecordProducer {
/**
* Sends (un-keyed) values synchronously to a Kafka topic.
*
* @param sendRequest
* the configuration of the producer and the send operation it has to carry out
* @param
* refers to the type of values being send
* @throws RuntimeException
* in case there is an error while sending an individual Kafka record to the
* designated Kafka broker
* @throws InterruptedException
* in case an interrupt signal has been set
* @return
* unmodifiable {@link java.util.List} that contains metadata on the written
* Kafka records
* @see SendValues
*/
List send(SendValues sendRequest) throws InterruptedException;
/**
* Sends (un-keyed) values synchronously and transactionally to a Kafka topic.
*
* @param sendRequest
* the configuration of the producer and the send operation it has to carry out
* @param
* refers to the type of values being send
* @throws RuntimeException
* in case there is an error while sending an individual Kafka record to the
* designated Kafka broker
* @throws InterruptedException
* in case an interrupt signal has been set
* @return
* unmodifiable {@link java.util.List} that contains metadata on the written
* Kafka records
* @see SendValuesTransactional
*/
List send(SendValuesTransactional sendRequest) throws InterruptedException;
/**
* Sends key-value pairs synchronously to a Kafka topic.
*
* @param sendRequest
* the configuration of the producer and the send operation it has to carry out
* @param
* refers to the type of keys being send
* @param
* refers to the type of values being send
* @throws RuntimeException
* in case there is an error while sending an individual Kafka record to the
* designated Kafka broker
* @throws InterruptedException
* in case an interrupt signal has been set
* @return
* unmodifiable {@link java.util.List} that contains metadata on the written
* Kafka records
* @see SendKeyValues
*/
List send(SendKeyValues sendRequest) throws InterruptedException;
/**
* Sends key-value pairs synchronously and transactionally to a Kafka topic.
*
* @param sendRequest
* the configuration of the producer and the send operation it has to carry out
* @param
* refers to the type of keys being send
* @param
* refers to the type of values being send
* @throws RuntimeException
* in case there is an error while sending an individual Kafka record to the
* designated Kafka broker
* @throws InterruptedException
* in case an interrupt signal has been set
* @return
* unmodifiable {@link java.util.List} that contains metadata on the written
* Kafka records
* @see SendKeyValuesTransactional
*/
List send(SendKeyValuesTransactional sendRequest) throws InterruptedException;
}