Interface Consumer<K,V>

All Superinterfaces:
AutoCloseable, Closeable

public interface Consumer<K,V> extends Closeable
A common interface of Kafka consumer.
  • Method Details

    • subscribe

      void subscribe(Collection<String> topics)
    • subscribe

      default void subscribe(String topic)
    • receive

      @NonNull @NonNull List<ConsumerRecord<K,V>> receive(long timeoutMs)
    • receiveUntil

      default List<ConsumerRecord<K,V>> receiveUntil(int maxNumMessages, long timeoutMs)
      Receive messages as much as possible until the number of received messages time exceeds limit or timed out.
      Parameters:
      maxNumMessages - the limited number of received messages
      timeoutMs - the total timeout in milliseconds for this method
      Returns:
      the total received messages
    • listTopics

      Map<String,List<org.apache.kafka.common.PartitionInfo>> listTopics(long timeoutMS)
    • commitOffsetSync

      void commitOffsetSync(List<TopicOffsetAndMetadata> offsets, Duration timeout)