io.vertx.kafka.client.consumer

## Interface KafkaReadStream<K,V>

- All Superinterfaces:
    ReadStream<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>, StreamBase

      public interface KafkaReadStream<K,V>
      extends ReadStream<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>

  A `ReadStream` for consuming Kafka `ConsumerRecord`.

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

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

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `KafkaReadStream<K,V>` | `assign(Set<org.apache.kafka.common.TopicPartition> partitions)` Manually assign a list of partition to this consumer.
    `KafkaReadStream<K,V>` | `assign(Set<org.apache.kafka.common.TopicPartition> partitions, Handler<AsyncResult<Void>> completionHandler)` Manually assign a list of partition to this consumer.
    `KafkaReadStream<K,V>` | `assignment(Handler<AsyncResult<Set<org.apache.kafka.common.TopicPartition>>> handler)` Get the set of partitions currently assigned to this consumer.
    `default void` | `close()` Close the stream
    `void` | `close(Handler<AsyncResult<Void>> completionHandler)` Close the stream
    `void` | `commit()` Commit current offsets for all the subscribed list of topics and partition.
    `void` | `commit(Handler<AsyncResult<Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata>>> completionHandler)` Commit current offsets for all the subscribed list of topics and partition.
    `void` | `commit(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> offsets)` Commit the specified offsets for the specified list of topics and partitions to Kafka.
    `void` | `commit(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> offsets, Handler<AsyncResult<Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata>>> completionHandler)` Commit the specified offsets for the specified list of topics and partitions to Kafka.
    `void` | `committed(org.apache.kafka.common.TopicPartition topicPartition, Handler<AsyncResult<org.apache.kafka.clients.consumer.OffsetAndMetadata>> handler)` Get the last committed offset for the given partition (whether the commit happened by this process or another).
    `org.apache.kafka.clients.consumer.Consumer<K,V>` | `consumer()`
    `static <K,V> KafkaReadStream<K,V>` | `create(Vertx vertx, org.apache.kafka.clients.consumer.Consumer<K,V> consumer)` Create a new KafkaReadStream instance
    `static <K,V> KafkaReadStream<K,V>` | `create(Vertx vertx, Map<String,Object> config)` Create a new KafkaReadStream instance
    `static <K,V> KafkaReadStream<K,V>` | `create(Vertx vertx, Map<String,Object> config, Class<K> keyType, Class<V> valueType)` Create a new KafkaReadStream instance
    `static <K,V> KafkaReadStream<K,V>` | `create(Vertx vertx, Properties config)` Create a new KafkaReadStream instance
    `static <K,V> KafkaReadStream<K,V>` | `create(Vertx vertx, Properties config, Class<K> keyType, Class<V> valueType)` Create a new KafkaReadStream instance
    `KafkaReadStream<K,V>` | `listTopics(Handler<AsyncResult<Map<String,List<org.apache.kafka.common.PartitionInfo>>>> handler)` Get metadata about partitions for all topics that the user is authorized to view.
    `KafkaReadStream<K,V>` | `partitionsAssignedHandler(Handler<Set<org.apache.kafka.common.TopicPartition>> handler)` Set the handler called when topic partitions are assigned to the consumer
    `KafkaReadStream<K,V>` | `partitionsFor(String topic, Handler<AsyncResult<List<org.apache.kafka.common.PartitionInfo>>> handler)` Get metadata about the partitions for a given topic.
    `KafkaReadStream<K,V>` | `partitionsRevokedHandler(Handler<Set<org.apache.kafka.common.TopicPartition>> handler)` Set the handler called when topic partitions are revoked to the consumer
    `KafkaReadStream<K,V>` | `pause(Set<org.apache.kafka.common.TopicPartition> topicPartitions)` Suspend fetching from the requested partitions.
    `KafkaReadStream<K,V>` | `pause(Set<org.apache.kafka.common.TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)` Suspend fetching from the requested partitions.
    `void` | `paused(Handler<AsyncResult<Set<org.apache.kafka.common.TopicPartition>>> handler)` Get the set of partitions that were previously paused by a call to `pause(Set)`.
    `void` | `position(org.apache.kafka.common.TopicPartition partition, Handler<AsyncResult<Long>> handler)` Get the offset of the next record that will be fetched (if a record with that offset exists).
    `KafkaReadStream<K,V>` | `resume(Set<org.apache.kafka.common.TopicPartition> topicPartitions)` Resume specified partitions which have been paused with pause.
    `KafkaReadStream<K,V>` | `resume(Set<org.apache.kafka.common.TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)` Resume specified partitions which have been paused with pause.
    `KafkaReadStream<K,V>` | `seek(org.apache.kafka.common.TopicPartition topicPartition, long offset)` Overrides the fetch offsets that the consumer will use on the next poll.
    `KafkaReadStream<K,V>` | `seek(org.apache.kafka.common.TopicPartition topicPartition, long offset, Handler<AsyncResult<Void>> completionHandler)` Overrides the fetch offsets that the consumer will use on the next poll.
    `KafkaReadStream<K,V>` | `seekToBeginning(Set<org.apache.kafka.common.TopicPartition> topicPartitions)` Seek to the first offset for each of the given partitions.
    `KafkaReadStream<K,V>` | `seekToBeginning(Set<org.apache.kafka.common.TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)` Seek to the first offset for each of the given partitions.
    `KafkaReadStream<K,V>` | `seekToEnd(Set<org.apache.kafka.common.TopicPartition> topicPartitions)` Seek to the last offset for each of the given partitions.
    `KafkaReadStream<K,V>` | `seekToEnd(Set<org.apache.kafka.common.TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)` Seek to the last offset for each of the given partitions.
    `KafkaReadStream<K,V>` | `subscribe(Set<String> topics)` Subscribe to the given list of topics to get dynamically assigned partitions.
    `KafkaReadStream<K,V>` | `subscribe(Set<String> topics, Handler<AsyncResult<Void>> completionHandler)` Subscribe to the given list of topics to get dynamically assigned partitions.
    `KafkaReadStream<K,V>` | `subscription(Handler<AsyncResult<Set<String>>> handler)` Get the current subscription.
    `KafkaReadStream<K,V>` | `unsubscribe()` Unsubscribe from topics currently subscribed with subscribe.
    `KafkaReadStream<K,V>` | `unsubscribe(Handler<AsyncResult<Void>> completionHandler)` Unsubscribe from topics currently subscribed with subscribe.

    - ### Methods inherited from interface io.vertx.core.streams.ReadStream

      `endHandler, exceptionHandler, handler, pause, resume`

- - ### Method Detail

    - #### create

          static <K,V> KafkaReadStream<K,V> create(Vertx vertx,
                                                   Properties config)

      Create a new KafkaReadStream instance
      Parameters:
        `vertx` - Vert.x instance to use
        `config` - Kafka consumer configuration
      Returns:
        an instance of the KafkaReadStream

    - #### create

          static <K,V> KafkaReadStream<K,V> create(Vertx vertx,
                                                   Properties config,
                                                   Class<K> keyType,
                                                   Class<V> valueType)

      Create a new KafkaReadStream instance
      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 KafkaReadStream

    - #### create

          static <K,V> KafkaReadStream<K,V> create(Vertx vertx,
                                                   Map<String,Object> config)

      Create a new KafkaReadStream instance
      Parameters:
        `vertx` - Vert.x instance to use
        `config` - Kafka consumer configuration
      Returns:
        an instance of the KafkaReadStream

    - #### create

          static <K,V> KafkaReadStream<K,V> create(Vertx vertx,
                                                   Map<String,Object> config,
                                                   Class<K> keyType,
                                                   Class<V> valueType)

      Create a new KafkaReadStream instance
      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 KafkaReadStream

    - #### create

          static <K,V> KafkaReadStream<K,V> create(Vertx vertx,
                                                   org.apache.kafka.clients.consumer.Consumer<K,V> consumer)

      Create a new KafkaReadStream instance
      Parameters:
        `vertx` - Vert.x instance to use
        `consumer` - native Kafka consumer instance
      Returns:
        an instance of the KafkaReadStream

    - #### committed

          void committed(org.apache.kafka.common.TopicPartition topicPartition,
                         Handler<AsyncResult<org.apache.kafka.clients.consumer.OffsetAndMetadata>> handler)

      Get the last committed offset for the given partition (whether the commit happened by this process or another).
      Parameters:
        `topicPartition` - topic partition for getting last committed offset
        `handler` - handler called on operation completed

    - #### pause

          KafkaReadStream<K,V> pause(Set<org.apache.kafka.common.TopicPartition> topicPartitions)

      Suspend fetching from the requested partitions.
      Parameters:
        `topicPartitions` - topic partition from which suspend fetching
      Returns:
        current KafkaReadStream instance

    - #### pause

          KafkaReadStream<K,V> pause(Set<org.apache.kafka.common.TopicPartition> topicPartitions,
                                     Handler<AsyncResult<Void>> completionHandler)

      Suspend fetching from the requested partitions.
      Parameters:
        `topicPartitions` - topic partition from which suspend fetching
        `completionHandler` - handler called on operation completed
      Returns:
        current KafkaReadStream instance

    - #### paused

          void paused(Handler<AsyncResult<Set<org.apache.kafka.common.TopicPartition>>> handler)

      Get the set of partitions that were previously paused by a call to `pause(Set)`.
      Parameters:
        `handler` - handler called on operation completed

    - #### resume

          KafkaReadStream<K,V> resume(Set<org.apache.kafka.common.TopicPartition> topicPartitions)

      Resume specified partitions which have been paused with pause.
      Parameters:
        `topicPartitions` - topic partition from which resume fetching
      Returns:
        current KafkaReadStream instance

    - #### resume

          KafkaReadStream<K,V> resume(Set<org.apache.kafka.common.TopicPartition> topicPartitions,
                                      Handler<AsyncResult<Void>> completionHandler)

      Resume specified partitions which have been paused with pause.
      Parameters:
        `topicPartitions` - topic partition from which resume fetching
        `completionHandler` - handler called on operation completed
      Returns:
        current KafkaReadStream instance

    - #### seekToEnd

          KafkaReadStream<K,V> seekToEnd(Set<org.apache.kafka.common.TopicPartition> topicPartitions)

      Seek to the last offset for each of the given partitions.
      Parameters:
        `topicPartitions` - topic partition for which seek
      Returns:
        current KafkaReadStream instance

    - #### seekToEnd

          KafkaReadStream<K,V> seekToEnd(Set<org.apache.kafka.common.TopicPartition> topicPartitions,
                                         Handler<AsyncResult<Void>> completionHandler)

      Seek to the last offset for each of the given partitions.
      Parameters:
        `topicPartitions` - topic partition for which seek
        `completionHandler` - handler called on operation completed
      Returns:
        current KafkaReadStream instance

    - #### seekToBeginning

          KafkaReadStream<K,V> seekToBeginning(Set<org.apache.kafka.common.TopicPartition> topicPartitions)

      Seek to the first offset for each of the given partitions.
      Parameters:
        `topicPartitions` - topic partition for which seek
      Returns:
        current KafkaReadStream instance

    - #### seekToBeginning

          KafkaReadStream<K,V> seekToBeginning(Set<org.apache.kafka.common.TopicPartition> topicPartitions,
                                               Handler<AsyncResult<Void>> completionHandler)

      Seek to the first offset for each of the given partitions.
      Parameters:
        `topicPartitions` - topic partition for which seek
        `completionHandler` - handler called on operation completed
      Returns:
        current KafkaReadStream instance

    - #### seek

          KafkaReadStream<K,V> seek(org.apache.kafka.common.TopicPartition topicPartition,
                                    long offset)

      Overrides the fetch offsets that the consumer will use on the next poll.
      Parameters:
        `topicPartition` - topic partition for which seek
        `offset` - offset to seek inside the topic partition
      Returns:
        current KafkaReadStream instance

    - #### seek

          KafkaReadStream<K,V> seek(org.apache.kafka.common.TopicPartition topicPartition,
                                    long offset,
                                    Handler<AsyncResult<Void>> completionHandler)

      Overrides the fetch offsets that the consumer will use on the next poll.
      Parameters:
        `topicPartition` - topic partition for which seek
        `offset` - offset to seek inside the topic partition
        `completionHandler` - handler called on operation completed
      Returns:
        current KafkaReadStream instance

    - #### partitionsRevokedHandler

          KafkaReadStream<K,V> partitionsRevokedHandler(Handler<Set<org.apache.kafka.common.TopicPartition>> handler)

      Set the handler called when topic partitions are revoked to the consumer
      Parameters:
        `handler` - handler called on revoked topic partitions
      Returns:
        current KafkaReadStream instance

    - #### partitionsAssignedHandler

          KafkaReadStream<K,V> partitionsAssignedHandler(Handler<Set<org.apache.kafka.common.TopicPartition>> handler)

      Set the handler called when topic partitions are assigned to the consumer
      Parameters:
        `handler` - handler called on assigned topic partitions
      Returns:
        current KafkaReadStream instance

    - #### subscribe

          KafkaReadStream<K,V> subscribe(Set<String> topics)

      Subscribe to the given list of topics to get dynamically assigned partitions.
      Parameters:
        `topics` - topics to subscribe to
      Returns:
        current KafkaReadStream instance

    - #### subscribe

          KafkaReadStream<K,V> subscribe(Set<String> topics,
                                         Handler<AsyncResult<Void>> completionHandler)

      Subscribe to the given list of topics to get dynamically assigned partitions.
      Parameters:
        `topics` - topics to subscribe to
        `completionHandler` - handler called on operation completed
      Returns:
        current KafkaReadStream instance

    - #### unsubscribe

          KafkaReadStream<K,V> unsubscribe()

      Unsubscribe from topics currently subscribed with subscribe.
      Returns:
        current KafkaReadStream instance

    - #### unsubscribe

          KafkaReadStream<K,V> unsubscribe(Handler<AsyncResult<Void>> completionHandler)

      Unsubscribe from topics currently subscribed with subscribe.
      Parameters:
        `completionHandler` - handler called on operation completed
      Returns:
        current KafkaReadStream instance

    - #### subscription

          KafkaReadStream<K,V> subscription(Handler<AsyncResult<Set<String>>> handler)

      Get the current subscription.
      Parameters:
        `handler` - handler called on operation completed
      Returns:
        current KafkaReadStream instance

    - #### assign

          KafkaReadStream<K,V> assign(Set<org.apache.kafka.common.TopicPartition> partitions)

      Manually assign a list of partition to this consumer.
      Parameters:
        `partitions` - partitions which want assigned
      Returns:
        current KafkaReadStream instance

    - #### assign

          KafkaReadStream<K,V> assign(Set<org.apache.kafka.common.TopicPartition> partitions,
                                      Handler<AsyncResult<Void>> completionHandler)

      Manually assign a list of partition to this consumer.
      Parameters:
        `partitions` - partitions which want assigned
        `completionHandler` - handler called on operation completed
      Returns:
        current KafkaReadStream instance

    - #### assignment

          KafkaReadStream<K,V> assignment(Handler<AsyncResult<Set<org.apache.kafka.common.TopicPartition>>> handler)

      Get the set of partitions currently assigned to this consumer.
      Parameters:
        `handler` - handler called on operation completed
      Returns:
        current KafkaReadStream instance

    - #### listTopics

          KafkaReadStream<K,V> listTopics(Handler<AsyncResult<Map<String,List<org.apache.kafka.common.PartitionInfo>>>> handler)

      Get metadata about partitions for all topics that the user is authorized to view.
      Parameters:
        `handler` - handler called on operation completed
      Returns:
        current KafkaReadStream instance

    - #### commit

          void commit()

      Commit current offsets for all the subscribed list of topics and partition.

    - #### commit

          void commit(Handler<AsyncResult<Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata>>> completionHandler)

      Commit current offsets for all the subscribed list of topics and partition.
      Parameters:
        `completionHandler` - handler called on operation completed

    - #### commit

          void commit(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> offsets)

      Commit the specified offsets for the specified list of topics and partitions to Kafka.
      Parameters:
        `offsets` - offsets list to commit

    - #### commit

          void commit(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> offsets,
                      Handler<AsyncResult<Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata>>> completionHandler)

      Commit the specified offsets for the specified list of topics and partitions to Kafka.
      Parameters:
        `offsets` - offsets list to commit
        `completionHandler` - handler called on operation completed

    - #### partitionsFor

          KafkaReadStream<K,V> partitionsFor(String topic,
                                             Handler<AsyncResult<List<org.apache.kafka.common.PartitionInfo>>> handler)

      Get metadata about the partitions for a given topic.
      Parameters:
        `topic` - topic partition for which getting partitions info
        `handler` - handler called on operation completed
      Returns:
        current KafkaReadStream instance

    - #### close

          default void close()

      Close the stream

    - #### close

          void close(Handler<AsyncResult<Void>> completionHandler)

      Close the stream
      Parameters:
        `completionHandler` - handler called on operation completed

    - #### position

          void position(org.apache.kafka.common.TopicPartition partition,
                        Handler<AsyncResult<Long>> handler)

      Get the offset of the next record that will be fetched (if a record with that offset exists).
      Parameters:
        `partition` - The partition to get the position for
        `handler` - handler called on operation completed

    - #### consumer

          org.apache.kafka.clients.consumer.Consumer<K,V> consumer()

      Returns:
        the native consumer

Copyright © 2017. All rights reserved.