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

net.mguenther.kafka.junit.RecordConsumer Maven / Gradle / Ivy

package net.mguenther.kafka.junit;

import java.util.List;

/**
 * Provides the means to read key-value pairs or un-keyed values from a Kafka topic as well
 * as the possibility to watch given topics until a certain amount of records have been consumed
 * from them. All of the operations a {@code RecordConsumer} provides are synchronous in their
 * nature.
 */
public interface RecordConsumer {

    /**
     * Reads values from a Kafka topic.
     *
     * @param readRequest
     *      the configuration of the consumer and the read operation it has to carry out
     * @param 
     *      refers to the type of values being read
     * @throws InterruptedException
     *      in case an interrupt signal has been set
     * @return
     *      unmodifiable {@link java.util.List} of consumed values
     * @see ReadKeyValues
     */
     List readValues(ReadKeyValues readRequest) throws InterruptedException;

    /**
     * Reads key-value pairs from a Kafka topic.
     *
     * @param readRequest
     *      the configuration of the consumer and the read operation it has to carry out
     * @param 
     *      refers to the type of keys being read
     * @param 
     *      refers to the type of values being read
     * @throws InterruptedException
     *      in case an interrupt signal has been set
     * @return
     *      unmodifiable {@link java.util.List} of consumed key-value pairs
     * @see ReadKeyValues
     */
     List> read(ReadKeyValues readRequest) throws InterruptedException;

    /**
     * Observes a Kafka topic until a certain amount of records have been consumed or a timeout
     * elapses. Returns the values that have been consumed up until this point of throws an
     * {@code AssertionError} if the number of consumed values does not meet the expected
     * number of records.
     *
     * @param observeRequest
     *      the configuration of the consumer and the observe operation it has to carry out
     * @param 
     *      refers to the type of values being read
     * @throws InterruptedException
     *      in case an interrupt signal has been set
     * @return
     *      unmodifiable {@link java.util.List} of values
     * @see ObserveKeyValues
     */
     List observeValues(ObserveKeyValues observeRequest) throws InterruptedException;

    /**
     * Observes a Kafka topic until a certain amount of records have been consumed or a timeout
     * elapses. Returns the key-value-pairs that have been consumed up until this point or throws an
     * {@code AssertionError} if the number of consumed key-value-pairs does not meet the expected
     * number of records.
     *
     * @param observeRequest
     *      the configuration of the consumer and the observe operation it has to carry out
     * @param 
     *      refers to the type of keys being read
     * @param 
     *      refers to the type of values being read
     * @throws InterruptedException
     *      in case an interrupt signal has been set
     * @return
     *      unmodifiable {@link java.util.List} of key-value pairs
     * @see ObserveKeyValues
     */
     List> observe(ObserveKeyValues observeRequest) throws InterruptedException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy