Class KafkaConsumer<K,V>

java.lang.Object
io.vertx.mutiny.kafka.client.consumer.KafkaConsumer<K,V>
All Implemented Interfaces:
MutinyDelegate, ReadStream<KafkaConsumerRecord<K,V>>, StreamBase

public class KafkaConsumer<K,V> extends Object implements MutinyDelegate, ReadStream<KafkaConsumerRecord<K,V>>
Vert.x Kafka consumer.

You receive Kafka records by providing a handler(java.util.function.Consumer<io.vertx.mutiny.kafka.client.consumer.KafkaConsumerRecord<K, V>>). As messages arrive the handler will be called with the records.

The pause() and resume() provides global control over reading the records from the consumer.

The pause() and resume() provides finer grained control over reading records for specific Topic/Partition, these are Kafka's specific operations.

NOTE: This class has been automatically generated from the original non Mutiny-ified interface using Vert.x codegen.

  • Field Details

  • Constructor Details

    • KafkaConsumer

      public KafkaConsumer(io.vertx.kafka.client.consumer.KafkaConsumer delegate)
    • KafkaConsumer

      public KafkaConsumer(Object delegate, TypeArg<K> typeArg_0, TypeArg<V> typeArg_1)
    • KafkaConsumer

      public KafkaConsumer(io.vertx.kafka.client.consumer.KafkaConsumer delegate, TypeArg<K> typeArg_0, TypeArg<V> typeArg_1)
  • Method Details

    • getDelegate

      public io.vertx.kafka.client.consumer.KafkaConsumer getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Specified by:
      getDelegate in interface ReadStream<K>
      Specified by:
      getDelegate in interface StreamBase
      Returns:
      the delegate used by this Mutiny object of generated type
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • pipe

      public Pipe<KafkaConsumerRecord<K,V>> pipe()
      Specified by:
      pipe in interface ReadStream<K>
      Returns:
      a pipe
    • pipeTo

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<KafkaConsumerRecord<K,V>> dst)
      Description copied from interface: ReadStream
      Pipe this ReadStream to the WriteStream.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Specified by:
      pipeTo in interface ReadStream<K>
      Parameters:
      dst - the destination write stream
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • pipeToAndAwait

      public Void pipeToAndAwait(WriteStream<KafkaConsumerRecord<K,V>> dst)
      Description copied from interface: ReadStream
      Blocking variant of ReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Specified by:
      pipeToAndAwait in interface ReadStream<K>
      Parameters:
      dst - the destination write stream
      Returns:
      the Void instance produced by the operation.
    • pipeToAndForget

      public void pipeToAndForget(WriteStream<KafkaConsumerRecord<K,V>> dst)
      Description copied from interface: ReadStream
      Variant of ReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream) that ignores the result of the operation.

      This method subscribes on the result of ReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from ReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream) but you don't need to compose it with other operations.

      Specified by:
      pipeToAndForget in interface ReadStream<K>
      Parameters:
      dst - the destination write stream
    • create

      public static <K, V> KafkaConsumer<K,V> create(Vertx vertx, Map<String,String> config)
      Parameters:
      vertx - Vert.x instance to use
      config - Kafka consumer configuration
      Returns:
      an instance of the KafkaConsumer
    • create

      public static <K, V> KafkaConsumer<K,V> create(Vertx vertx, Map<String,String> config, Class<K> keyType, Class<V> valueType)
      Parameters:
      vertx - Vert.x instance to use
      config - Kafka consumer configuration
      keyType - class type for the key deserialization
      valueType - class type for the value deserialization
      Returns:
      an instance of the KafkaConsumer
    • create

      public static <K, V> KafkaConsumer<K,V> create(Vertx vertx, io.vertx.kafka.client.common.KafkaClientOptions options)
      Parameters:
      vertx - Vert.x instance to use
      options - Kafka consumer options
      Returns:
      an instance of the KafkaConsumer
    • create

      public static <K, V> KafkaConsumer<K,V> create(Vertx vertx, io.vertx.kafka.client.common.KafkaClientOptions options, Class<K> keyType, Class<V> valueType)
      Parameters:
      vertx - Vert.x instance to use
      options - Kafka consumer options
      keyType - class type for the key deserialization
      valueType - class type for the value deserialization
      Returns:
      an instance of the KafkaConsumer
    • exceptionHandler

      public KafkaConsumer<K,V> exceptionHandler(Consumer<Throwable> handler)
      Specified by:
      exceptionHandler in interface ReadStream<K>
      Specified by:
      exceptionHandler in interface StreamBase
      Parameters:
      handler - the exception handler
      Returns:
    • handler

      public KafkaConsumer<K,V> handler(Consumer<KafkaConsumerRecord<K,V>> handler)
      Specified by:
      handler in interface ReadStream<K>
      Returns:
    • pause

      public KafkaConsumer<K,V> pause()
      Specified by:
      pause in interface ReadStream<K>
      Returns:
      a reference to this, so the API can be used fluently
    • resume

      public KafkaConsumer<K,V> resume()
      Specified by:
      resume in interface ReadStream<K>
      Returns:
      a reference to this, so the API can be used fluently
    • fetch

      public KafkaConsumer<K,V> fetch(long amount)
      Specified by:
      fetch in interface ReadStream<K>
      Returns:
      a reference to this, so the API can be used fluently
    • endHandler

      public KafkaConsumer<K,V> endHandler(Runnable endHandler)
      Specified by:
      endHandler in interface ReadStream<K>
      Returns:
    • demand

      public long demand()
      Returns:
      current demand
    • subscribe

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> subscribe(String topic)
      Subscribe to the given topic to get dynamically assigned partitions.

      Due to internal buffering of messages, when changing the subscribed topic the old topic may remain in effect (as observed by the record handler}) until some time after the given completionHandler is called. In contrast, the once the given completionHandler is called the batchHandler(java.util.function.Consumer<io.vertx.mutiny.kafka.client.consumer.KafkaConsumerRecords<K, V>>) will only see messages consistent with the new topic.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topic - topic to subscribe to
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • subscribeAndAwait

      public Void subscribeAndAwait(String topic)
      Blocking variant of subscribe(String).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topic - topic to subscribe to
      Returns:
      the Void instance produced by the operation.
    • subscribeAndForget

      public KafkaConsumer<K,V> subscribeAndForget(String topic)
      Variant of subscribe(String) that ignores the result of the operation.

      This method subscribes on the result of subscribe(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from subscribe(String) but you don't need to compose it with other operations.

      Parameters:
      topic - topic to subscribe to
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • subscribe

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> subscribe(Set<String> topics)
      Subscribe to the given list of topics to get dynamically assigned partitions.

      Due to internal buffering of messages, when changing the subscribed topics the old set of topics may remain in effect (as observed by the record handler}) until some time after the given completionHandler is called. In contrast, the once the given completionHandler is called the batchHandler(java.util.function.Consumer<io.vertx.mutiny.kafka.client.consumer.KafkaConsumerRecords<K, V>>) will only see messages consistent with the new set of topics.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topics - topics to subscribe to
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • subscribeAndAwait

      public Void subscribeAndAwait(Set<String> topics)
      Blocking variant of subscribe(Set).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topics - topics to subscribe to
      Returns:
      the Void instance produced by the operation.
    • subscribeAndForget

      public KafkaConsumer<K,V> subscribeAndForget(Set<String> topics)
      Variant of subscribe(Set) that ignores the result of the operation.

      This method subscribes on the result of subscribe(Set), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from subscribe(Set) but you don't need to compose it with other operations.

      Parameters:
      topics - topics to subscribe to
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • assign

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> assign(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Manually assign a partition to this consumer.

      Due to internal buffering of messages, when reassigning the old partition may remain in effect (as observed by the record handler)} until some time after the given completionHandler is called. In contrast, the once the given completionHandler is called the batchHandler(java.util.function.Consumer<io.vertx.mutiny.kafka.client.consumer.KafkaConsumerRecords<K, V>>) will only see messages consistent with the new partition.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartition - partition which want assigned
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • assignAndAwait

      public Void assignAndAwait(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Blocking variant of assign(TopicPartition).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartition - partition which want assigned
      Returns:
      the Void instance produced by the operation.
    • assignAndForget

      public KafkaConsumer<K,V> assignAndForget(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Variant of assign(TopicPartition) that ignores the result of the operation.

      This method subscribes on the result of assign(TopicPartition), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from assign(TopicPartition) but you don't need to compose it with other operations.

      Parameters:
      topicPartition - partition which want assigned
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • assign

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> assign(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Manually assign a list of partition to this consumer.

      Due to internal buffering of messages, when reassigning the old set of partitions may remain in effect (as observed by the record handler)} until some time after the given completionHandler is called. In contrast, the once the given completionHandler is called the batchHandler(java.util.function.Consumer<io.vertx.mutiny.kafka.client.consumer.KafkaConsumerRecords<K, V>>) will only see messages consistent with the new set of partitions.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartitions - partitions which want assigned
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • assignAndAwait

      public Void assignAndAwait(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Blocking variant of assign(Set).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartitions - partitions which want assigned
      Returns:
      the Void instance produced by the operation.
    • assignAndForget

      public KafkaConsumer<K,V> assignAndForget(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Variant of assign(Set) that ignores the result of the operation.

      This method subscribes on the result of assign(Set), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from assign(Set) but you don't need to compose it with other operations.

      Parameters:
      topicPartitions - partitions which want assigned
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • assignment

      @CheckReturnValue public io.smallrye.mutiny.Uni<Set<io.vertx.kafka.client.common.TopicPartition>> assignment()
      Get the set of partitions currently assigned to this consumer.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • assignmentAndAwait

      public Set<io.vertx.kafka.client.common.TopicPartition> assignmentAndAwait()
      Blocking variant of assignment().

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Returns:
      the Set instance produced by the operation.
    • assignmentAndForget

      public KafkaConsumer<K,V> assignmentAndForget()
      Variant of assignment() that ignores the result of the operation.

      This method subscribes on the result of assignment(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from assignment() but you don't need to compose it with other operations.

      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • unsubscribe

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> unsubscribe()
      Unsubscribe from topics currently subscribed with subscribe.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • unsubscribeAndAwait

      public Void unsubscribeAndAwait()
      Blocking variant of unsubscribe().

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Returns:
      the Void instance produced by the operation.
    • unsubscribeAndForget

      public KafkaConsumer<K,V> unsubscribeAndForget()
      Variant of unsubscribe() that ignores the result of the operation.

      This method subscribes on the result of unsubscribe(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from unsubscribe() but you don't need to compose it with other operations.

      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • subscription

      @CheckReturnValue public io.smallrye.mutiny.Uni<Set<String>> subscription()
      Get the current subscription.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • subscriptionAndAwait

      public Set<String> subscriptionAndAwait()
      Blocking variant of subscription().

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Returns:
      the Set instance produced by the operation.
    • subscriptionAndForget

      public KafkaConsumer<K,V> subscriptionAndForget()
      Variant of subscription() that ignores the result of the operation.

      This method subscribes on the result of subscription(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from subscription() but you don't need to compose it with other operations.

      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • pause

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> pause(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Suspend fetching from the requested partition.

      Due to internal buffering of messages, the will continue to observe messages from the given topicPartition until some time after the given completionHandler is called. In contrast, the once the given completionHandler is called the batchHandler(java.util.function.Consumer<io.vertx.mutiny.kafka.client.consumer.KafkaConsumerRecords<K, V>>) will not see messages from the given topicPartition.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartition - topic partition from which suspend fetching
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • pauseAndAwait

      public Void pauseAndAwait(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Blocking variant of pause(TopicPartition).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartition - topic partition from which suspend fetching
      Returns:
      the Void instance produced by the operation.
    • pauseAndForget

      public KafkaConsumer<K,V> pauseAndForget(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Variant of pause(TopicPartition) that ignores the result of the operation.

      This method subscribes on the result of pause(TopicPartition), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from pause(TopicPartition) but you don't need to compose it with other operations.

      Parameters:
      topicPartition - topic partition from which suspend fetching
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • pause

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> pause(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Suspend fetching from the requested partitions.

      Due to internal buffering of messages, the will continue to observe messages from the given topicPartitions until some time after the given completionHandler is called. In contrast, the once the given completionHandler is called the batchHandler(java.util.function.Consumer<io.vertx.mutiny.kafka.client.consumer.KafkaConsumerRecords<K, V>>) will not see messages from the given topicPartitions.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartitions - topic partition from which suspend fetching
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • pauseAndAwait

      public Void pauseAndAwait(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Blocking variant of pause(Set).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartitions - topic partition from which suspend fetching
      Returns:
      the Void instance produced by the operation.
    • pauseAndForget

      public KafkaConsumer<K,V> pauseAndForget(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Variant of pause(Set) that ignores the result of the operation.

      This method subscribes on the result of pause(Set), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from pause(Set) but you don't need to compose it with other operations.

      Parameters:
      topicPartitions - topic partition from which suspend fetching
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • paused

      @CheckReturnValue public io.smallrye.mutiny.Uni<Set<io.vertx.kafka.client.common.TopicPartition>> paused()
      Get the set of partitions that were previously paused by a call to pause(Set).

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • pausedAndAwait

      public Set<io.vertx.kafka.client.common.TopicPartition> pausedAndAwait()
      Blocking variant of paused().

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Returns:
      the Set instance produced by the operation.
    • pausedAndForget

      public void pausedAndForget()
      Variant of paused() that ignores the result of the operation.

      This method subscribes on the result of paused(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from paused() but you don't need to compose it with other operations.

    • resume

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> resume(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Resume specified partition which have been paused with pause.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartition - topic partition from which resume fetching
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • resumeAndAwait

      public Void resumeAndAwait(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Blocking variant of resume(TopicPartition).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartition - topic partition from which resume fetching
      Returns:
      the Void instance produced by the operation.
    • resumeAndForget

      public KafkaConsumer<K,V> resumeAndForget(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Variant of resume(TopicPartition) that ignores the result of the operation.

      This method subscribes on the result of resume(TopicPartition), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from resume(TopicPartition) but you don't need to compose it with other operations.

      Parameters:
      topicPartition - topic partition from which resume fetching
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • resume

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> resume(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Resume specified partitions which have been paused with pause.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartitions - topic partition from which resume fetching
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • resumeAndAwait

      public Void resumeAndAwait(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Blocking variant of resume(Set).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartitions - topic partition from which resume fetching
      Returns:
      the Void instance produced by the operation.
    • resumeAndForget

      public KafkaConsumer<K,V> resumeAndForget(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Variant of resume(Set) that ignores the result of the operation.

      This method subscribes on the result of resume(Set), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from resume(Set) but you don't need to compose it with other operations.

      Parameters:
      topicPartitions - topic partition from which resume fetching
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • partitionsRevokedHandler

      public KafkaConsumer<K,V> partitionsRevokedHandler(Consumer<Set<io.vertx.kafka.client.common.TopicPartition>> handler)
      Parameters:
      handler - handler called on revoked topic partitions
      Returns:
    • partitionsAssignedHandler

      public KafkaConsumer<K,V> partitionsAssignedHandler(Consumer<Set<io.vertx.kafka.client.common.TopicPartition>> handler)
      Parameters:
      handler - handler called on assigned topic partitions
      Returns:
    • seek

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> seek(io.vertx.kafka.client.common.TopicPartition topicPartition, long offset)
      Overrides the fetch offsets that the consumer will use on the next poll.

      Due to internal buffering of messages, the will continue to observe messages fetched with respect to the old offset until some time after the given completionHandler is called. In contrast, the once the given completionHandler is called the batchHandler(java.util.function.Consumer<io.vertx.mutiny.kafka.client.consumer.KafkaConsumerRecords<K, V>>) will only see messages consistent with the new offset.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartition - topic partition for which seek
      offset - offset to seek inside the topic partition
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • seekAndAwait

      public Void seekAndAwait(io.vertx.kafka.client.common.TopicPartition topicPartition, long offset)
      Blocking variant of seek(TopicPartition,long).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartition - topic partition for which seek
      offset - offset to seek inside the topic partition
      Returns:
      the Void instance produced by the operation.
    • seekAndForget

      public KafkaConsumer<K,V> seekAndForget(io.vertx.kafka.client.common.TopicPartition topicPartition, long offset)
      Variant of seek(TopicPartition,long) that ignores the result of the operation.

      This method subscribes on the result of seek(TopicPartition,long), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from seek(TopicPartition,long) but you don't need to compose it with other operations.

      Parameters:
      topicPartition - topic partition for which seek
      offset - offset to seek inside the topic partition
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • seekToBeginning

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> seekToBeginning(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Seek to the first offset for each of the given partition.

      Due to internal buffering of messages, the will continue to observe messages fetched with respect to the old offset until some time after the given completionHandler is called. In contrast, the once the given completionHandler is called the batchHandler(java.util.function.Consumer<io.vertx.mutiny.kafka.client.consumer.KafkaConsumerRecords<K, V>>) will only see messages consistent with the new offset.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartition - topic partition for which seek
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • seekToBeginningAndAwait

      public Void seekToBeginningAndAwait(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Blocking variant of seekToBeginning(TopicPartition).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartition - topic partition for which seek
      Returns:
      the Void instance produced by the operation.
    • seekToBeginningAndForget

      public KafkaConsumer<K,V> seekToBeginningAndForget(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Variant of seekToBeginning(TopicPartition) that ignores the result of the operation.

      This method subscribes on the result of seekToBeginning(TopicPartition), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from seekToBeginning(TopicPartition) but you don't need to compose it with other operations.

      Parameters:
      topicPartition - topic partition for which seek
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • seekToBeginning

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> seekToBeginning(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Seek to the first offset for each of the given partitions.

      Due to internal buffering of messages, the will continue to observe messages fetched with respect to the old offset until some time after the given completionHandler is called. In contrast, the once the given completionHandler is called the batchHandler(java.util.function.Consumer<io.vertx.mutiny.kafka.client.consumer.KafkaConsumerRecords<K, V>>) will only see messages consistent with the new offset.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartitions - topic partition for which seek
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • seekToBeginningAndAwait

      public Void seekToBeginningAndAwait(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Blocking variant of seekToBeginning(Set).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartitions - topic partition for which seek
      Returns:
      the Void instance produced by the operation.
    • seekToBeginningAndForget

      public KafkaConsumer<K,V> seekToBeginningAndForget(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Variant of seekToBeginning(Set) that ignores the result of the operation.

      This method subscribes on the result of seekToBeginning(Set), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from seekToBeginning(Set) but you don't need to compose it with other operations.

      Parameters:
      topicPartitions - topic partition for which seek
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • seekToEnd

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> seekToEnd(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Seek to the last offset for each of the given partition.

      Due to internal buffering of messages, the will continue to observe messages fetched with respect to the old offset until some time after the given completionHandler is called. In contrast, the once the given completionHandler is called the batchHandler(java.util.function.Consumer<io.vertx.mutiny.kafka.client.consumer.KafkaConsumerRecords<K, V>>) will only see messages consistent with the new offset.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartition - topic partition for which seek
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • seekToEndAndAwait

      public Void seekToEndAndAwait(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Blocking variant of seekToEnd(TopicPartition).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartition - topic partition for which seek
      Returns:
      the Void instance produced by the operation.
    • seekToEndAndForget

      public KafkaConsumer<K,V> seekToEndAndForget(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Variant of seekToEnd(TopicPartition) that ignores the result of the operation.

      This method subscribes on the result of seekToEnd(TopicPartition), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from seekToEnd(TopicPartition) but you don't need to compose it with other operations.

      Parameters:
      topicPartition - topic partition for which seek
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • seekToEnd

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> seekToEnd(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Seek to the last offset for each of the given partitions.

      Due to internal buffering of messages, the will continue to observe messages fetched with respect to the old offset until some time after the given completionHandler is called. In contrast, the once the given completionHandler is called the batchHandler(java.util.function.Consumer<io.vertx.mutiny.kafka.client.consumer.KafkaConsumerRecords<K, V>>) will only see messages consistent with the new offset.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartitions - topic partition for which seek
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • seekToEndAndAwait

      public Void seekToEndAndAwait(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Blocking variant of seekToEnd(Set).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartitions - topic partition for which seek
      Returns:
      the Void instance produced by the operation.
    • seekToEndAndForget

      public KafkaConsumer<K,V> seekToEndAndForget(Set<io.vertx.kafka.client.common.TopicPartition> topicPartitions)
      Variant of seekToEnd(Set) that ignores the result of the operation.

      This method subscribes on the result of seekToEnd(Set), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from seekToEnd(Set) but you don't need to compose it with other operations.

      Parameters:
      topicPartitions - topic partition for which seek
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • commit

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> commit()
      Commit current offsets for all the subscribed list of topics and partition.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • commitAndAwait

      public Void commitAndAwait()
      Blocking variant of commit().

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Returns:
      the Void instance produced by the operation.
    • commitAndForget

      public void commitAndForget()
      Variant of commit() that ignores the result of the operation.

      This method subscribes on the result of commit(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from commit() but you don't need to compose it with other operations.

    • committed

      @CheckReturnValue public io.smallrye.mutiny.Uni<io.vertx.kafka.client.consumer.OffsetAndMetadata> committed(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Get the last committed offset for the given partition (whether the commit happened by this process or another).

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartition - topic partition for getting last committed offset
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • committedAndAwait

      public io.vertx.kafka.client.consumer.OffsetAndMetadata committedAndAwait(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Blocking variant of committed(TopicPartition).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartition - topic partition for getting last committed offset
      Returns:
      the OffsetAndMetadata instance produced by the operation.
    • committedAndForget

      public void committedAndForget(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Variant of committed(TopicPartition) that ignores the result of the operation.

      This method subscribes on the result of committed(TopicPartition), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from committed(TopicPartition) but you don't need to compose it with other operations.

      Parameters:
      topicPartition - topic partition for getting last committed offset
    • partitionsFor

      @CheckReturnValue public io.smallrye.mutiny.Uni<List<io.vertx.kafka.client.common.PartitionInfo>> partitionsFor(String topic)
      Get metadata about the partitions for a given topic.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topic - topic partition for which getting partitions info
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • partitionsForAndAwait

      public List<io.vertx.kafka.client.common.PartitionInfo> partitionsForAndAwait(String topic)
      Blocking variant of partitionsFor(String).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topic - topic partition for which getting partitions info
      Returns:
      the List instance produced by the operation.
    • partitionsForAndForget

      public KafkaConsumer<K,V> partitionsForAndForget(String topic)
      Variant of partitionsFor(String) that ignores the result of the operation.

      This method subscribes on the result of partitionsFor(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from partitionsFor(String) but you don't need to compose it with other operations.

      Parameters:
      topic - topic partition for which getting partitions info
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • batchHandler

      public KafkaConsumer<K,V> batchHandler(Consumer<KafkaConsumerRecords<K,V>> handler)
      Parameters:
      handler - handler called when batches of messages are fetched
      Returns:
    • close

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> close()
      Close the consumer

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • closeAndAwait

      public Void closeAndAwait()
      Blocking variant of close().

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Returns:
      the Void instance produced by the operation.
    • closeAndForget

      public void closeAndForget()
      Variant of close() that ignores the result of the operation.

      This method subscribes on the result of close(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from close() but you don't need to compose it with other operations.

    • position

      @CheckReturnValue public io.smallrye.mutiny.Uni<Long> position(io.vertx.kafka.client.common.TopicPartition partition)
      Get the offset of the next record that will be fetched (if a record with that offset exists).

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      partition - The partition to get the position for
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • positionAndAwait

      public Long positionAndAwait(io.vertx.kafka.client.common.TopicPartition partition)
      Blocking variant of position(TopicPartition).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      partition - The partition to get the position for
      Returns:
      the Long instance produced by the operation.
    • positionAndForget

      public void positionAndForget(io.vertx.kafka.client.common.TopicPartition partition)
      Variant of position(TopicPartition) that ignores the result of the operation.

      This method subscribes on the result of position(TopicPartition), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from position(TopicPartition) but you don't need to compose it with other operations.

      Parameters:
      partition - The partition to get the position for
    • offsetsForTimes

      @CheckReturnValue public io.smallrye.mutiny.Uni<io.vertx.kafka.client.consumer.OffsetAndTimestamp> offsetsForTimes(io.vertx.kafka.client.common.TopicPartition topicPartition, Long timestamp)
      Look up the offset for the given partition by timestamp. Note: the result might be null in case for the given timestamp no offset can be found -- e.g., when the timestamp refers to the future

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartition - TopicPartition to query.
      timestamp - Timestamp to be used in the query.
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • offsetsForTimesAndAwait

      public io.vertx.kafka.client.consumer.OffsetAndTimestamp offsetsForTimesAndAwait(io.vertx.kafka.client.common.TopicPartition topicPartition, Long timestamp)
      Blocking variant of offsetsForTimes(TopicPartition,Long).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartition - TopicPartition to query.
      timestamp - Timestamp to be used in the query.
      Returns:
      the OffsetAndTimestamp instance produced by the operation.
    • offsetsForTimesAndForget

      public void offsetsForTimesAndForget(io.vertx.kafka.client.common.TopicPartition topicPartition, Long timestamp)
      Variant of offsetsForTimes(TopicPartition,Long) that ignores the result of the operation.

      This method subscribes on the result of offsetsForTimes(TopicPartition,Long), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from offsetsForTimes(TopicPartition,Long) but you don't need to compose it with other operations.

      Parameters:
      topicPartition - TopicPartition to query.
      timestamp - Timestamp to be used in the query.
    • beginningOffsets

      @CheckReturnValue public io.smallrye.mutiny.Uni<Long> beginningOffsets(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Get the first offset for the given partitions.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartition - the partition to get the earliest offset.
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • beginningOffsetsAndAwait

      public Long beginningOffsetsAndAwait(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Blocking variant of beginningOffsets(TopicPartition).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartition - the partition to get the earliest offset.
      Returns:
      the Long instance produced by the operation.
    • beginningOffsetsAndForget

      public void beginningOffsetsAndForget(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Variant of beginningOffsets(TopicPartition) that ignores the result of the operation.

      This method subscribes on the result of beginningOffsets(TopicPartition), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from beginningOffsets(TopicPartition) but you don't need to compose it with other operations.

      Parameters:
      topicPartition - the partition to get the earliest offset.
    • endOffsets

      @CheckReturnValue public io.smallrye.mutiny.Uni<Long> endOffsets(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Get the last offset for the given partition. The last offset of a partition is the offset of the upcoming message, i.e. the offset of the last available message + 1.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topicPartition - the partition to get the end offset.
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • endOffsetsAndAwait

      public Long endOffsetsAndAwait(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Blocking variant of endOffsets(TopicPartition).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topicPartition - the partition to get the end offset.
      Returns:
      the Long instance produced by the operation.
    • endOffsetsAndForget

      public void endOffsetsAndForget(io.vertx.kafka.client.common.TopicPartition topicPartition)
      Variant of endOffsets(TopicPartition) that ignores the result of the operation.

      This method subscribes on the result of endOffsets(TopicPartition), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from endOffsets(TopicPartition) but you don't need to compose it with other operations.

      Parameters:
      topicPartition - the partition to get the end offset.
    • create

      public static <K, V> KafkaConsumer<K,V> create(Vertx vertx, org.apache.kafka.clients.consumer.Consumer<K,V> consumer)
      Parameters:
      vertx - Vert.x instance to use
      consumer - the Kafka consumer to wrap
      Returns:
      an instance of the KafkaConsumer
    • create

      public static <K, V> KafkaConsumer<K,V> create(Vertx vertx, org.apache.kafka.clients.consumer.Consumer<K,V> consumer, io.vertx.kafka.client.common.KafkaClientOptions options)
      Parameters:
      vertx - Vert.x instance to use
      consumer - the Kafka consumer to wrap
      options - options used only for tracing settings
      Returns:
      an instance of the KafkaConsumer
    • pollTimeout

      public KafkaConsumer<K,V> pollTimeout(Duration timeout)
      Parameters:
      timeout - The time, spent waiting in poll if data is not available in the buffer. If 0, returns immediately with any records that are available currently in the native Kafka consumer's buffer, else returns empty. Must not be negative.
      Returns:
      the instance of KafkaConsumer<K,V> to chain method calls.
    • poll

      @CheckReturnValue public io.smallrye.mutiny.Uni<KafkaConsumerRecords<K,V>> poll(Duration timeout)
      Executes a poll for getting messages from Kafka.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      timeout - The maximum time to block (must not be greater than Long milliseconds)
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • pollAndAwait

      public KafkaConsumerRecords<K,V> pollAndAwait(Duration timeout)
      Blocking variant of poll(Duration).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      timeout - The maximum time to block (must not be greater than Long milliseconds)
      Returns:
      the KafkaConsumerRecords<K,V> instance produced by the operation.
    • pollAndForget

      public void pollAndForget(Duration timeout)
      Variant of poll(Duration) that ignores the result of the operation.

      This method subscribes on the result of poll(Duration), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from poll(Duration) but you don't need to compose it with other operations.

      Parameters:
      timeout - The maximum time to block (must not be greater than Long milliseconds)
    • toMulti

      @CheckReturnValue public io.smallrye.mutiny.Multi<KafkaConsumerRecord<K,V>> toMulti()
      Specified by:
      toMulti in interface ReadStream<K>
    • toBlockingIterable

      public Iterable<KafkaConsumerRecord<K,V>> toBlockingIterable()
    • toBlockingStream

      public Stream<KafkaConsumerRecord<K,V>> toBlockingStream()
    • newInstance

      public static <K, V> KafkaConsumer<K,V> newInstance(io.vertx.kafka.client.consumer.KafkaConsumer arg)
    • newInstance

      public static <K, V> KafkaConsumer<K,V> newInstance(io.vertx.kafka.client.consumer.KafkaConsumer arg, TypeArg<K> __typeArg_K, TypeArg<V> __typeArg_V)