vertx / io.vertx.reactivex.kafka.client.consumer / KafkaConsumer

KafkaConsumer

open class KafkaConsumer<K : Any, V : Any> : ReadStream<KafkaConsumerRecord<K, V>>

Vert.x Kafka consumer.

You receive Kafka records by providing a io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#handler. As messages arrive the handler will be called with the records.

The io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#pause and io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#resume provides global control over reading the records from the consumer.

The io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#pause and io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#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 io.vertx.kafka.client.consumer.KafkaConsumer non RX-ified interface using Vert.x codegen.

Constructors

<init>

KafkaConsumer(delegate: KafkaConsumer<Any, Any>)
KafkaConsumer(delegate: KafkaConsumer<Any, Any>, typeArg_0: TypeArg<K>, typeArg_1: TypeArg<V>)

Properties

__TYPE_ARG

static val __TYPE_ARG: TypeArg<KafkaConsumer<Any, Any>>

__typeArg_0

val __typeArg_0: TypeArg<K>

__typeArg_1

val __typeArg_1: TypeArg<V>

Functions

assign

open fun assign(topicPartition: TopicPartition): KafkaConsumer<K, V>
open fun assign(topicPartition: TopicPartition, completionHandler: Handler<AsyncResult<Void>>): KafkaConsumer<K, V>

Manually assign a partition to this consumer.

open fun assign(topicPartitions: MutableSet<TopicPartition>): KafkaConsumer<K, V>
open fun assign(topicPartitions: MutableSet<TopicPartition>, completionHandler: Handler<AsyncResult<Void>>): KafkaConsumer<K, V>

Manually assign a list of partition to this consumer.

assignment

open fun assignment(handler: Handler<AsyncResult<MutableSet<TopicPartition>>>): KafkaConsumer<K, V>

Get the set of partitions currently assigned to this consumer.

batchHandler

open fun batchHandler(handler: Handler<KafkaConsumerRecords<K, V>>): KafkaConsumer<K, V>

Set the handler to be used when batches of messages are fetched from the Kafka server. Batch handlers need to take care not to block the event loop when dealing with large batches. It is better to process records individually using the io.vertx.reactivex.kafka.client.consumer.KafkaConsumer.

beginningOffsets

open fun beginningOffsets(topicPartition: TopicPartition, handler: Handler<AsyncResult<Long>>): Unit

Get the first offset for the given partitions.

close

open fun close(): Unit
open fun close(completionHandler: Handler<AsyncResult<Void>>): Unit

Close the consumer

commit

open fun commit(): Unit
open fun commit(completionHandler: Handler<AsyncResult<Void>>): Unit

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

committed

open fun committed(topicPartition: TopicPartition, handler: Handler<AsyncResult<OffsetAndMetadata>>): Unit

Get the last committed offset for the given partition (whether the commit happened by this process or another).

create

open static fun <K : Any, V : Any> create(vertx: Vertx, config: MutableMap<String, String>): KafkaConsumer<K, V>
open static fun <K : Any, V : Any> create(vertx: Vertx, config: MutableMap<String, String>, keyType: Class<K>, valueType: Class<V>): KafkaConsumer<K, V>

Create a new KafkaConsumer instance

endHandler

open fun endHandler(endHandler: Handler<Void>): KafkaConsumer<K, V>

endOffsets

open fun endOffsets(topicPartition: TopicPartition, handler: Handler<AsyncResult<Long>>): Unit

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.

equals

open fun equals(other: Any?): Boolean

exceptionHandler

open fun exceptionHandler(handler: Handler<Throwable>): KafkaConsumer<K, V>

getDelegate

open fun getDelegate(): KafkaConsumer<Any, Any>

handler

open fun handler(handler: Handler<KafkaConsumerRecord<K, V>>): KafkaConsumer<K, V>

hashCode

open fun hashCode(): Int

newInstance

open static fun <K : Any, V : Any> newInstance(arg: KafkaConsumer<Any, Any>): KafkaConsumer<K, V>
open static fun <K : Any, V : Any> newInstance(arg: KafkaConsumer<Any, Any>, __typeArg_K: TypeArg<K>, __typeArg_V: TypeArg<V>): KafkaConsumer<K, V>

offsetsForTimes

open fun offsetsForTimes(topicPartition: TopicPartition, timestamp: Long, handler: Handler<AsyncResult<OffsetAndTimestamp>>): Unit

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

partitionsAssignedHandler

open fun partitionsAssignedHandler(handler: Handler<MutableSet<TopicPartition>>): KafkaConsumer<K, V>

Set the handler called when topic partitions are assigned to the consumer

partitionsFor

open fun partitionsFor(topic: String, handler: Handler<AsyncResult<MutableList<PartitionInfo>>>): KafkaConsumer<K, V>

Get metadata about the partitions for a given topic.

partitionsRevokedHandler

open fun partitionsRevokedHandler(handler: Handler<MutableSet<TopicPartition>>): KafkaConsumer<K, V>

Set the handler called when topic partitions are revoked to the consumer

pause

open fun pause(): KafkaConsumer<K, V>open fun pause(topicPartition: TopicPartition): KafkaConsumer<K, V>
open fun pause(topicPartition: TopicPartition, completionHandler: Handler<AsyncResult<Void>>): KafkaConsumer<K, V>

Suspend fetching from the requested partition.

open fun pause(topicPartitions: MutableSet<TopicPartition>): KafkaConsumer<K, V>
open fun pause(topicPartitions: MutableSet<TopicPartition>, completionHandler: Handler<AsyncResult<Void>>): KafkaConsumer<K, V>

Suspend fetching from the requested partitions.

paused

open fun paused(handler: Handler<AsyncResult<MutableSet<TopicPartition>>>): Unit

Get the set of partitions that were previously paused by a call to pause(Set).

position

open fun position(partition: TopicPartition, handler: Handler<AsyncResult<Long>>): Unit

Get the offset of the next record that will be fetched (if a record with that offset exists).

resume

open fun resume(): KafkaConsumer<K, V>open fun resume(topicPartition: TopicPartition): KafkaConsumer<K, V>
open fun resume(topicPartition: TopicPartition, completionHandler: Handler<AsyncResult<Void>>): KafkaConsumer<K, V>

Resume specified partition which have been paused with pause.

open fun resume(topicPartitions: MutableSet<TopicPartition>): KafkaConsumer<K, V>
open fun resume(topicPartitions: MutableSet<TopicPartition>, completionHandler: Handler<AsyncResult<Void>>): KafkaConsumer<K, V>

Resume specified partitions which have been paused with pause.

rxAssign

open fun rxAssign(topicPartition: TopicPartition): Completable

Manually assign a partition to this consumer.

open fun rxAssign(topicPartitions: MutableSet<TopicPartition>): Completable

Manually assign a list of partition to this consumer.

rxAssignment

open fun rxAssignment(): Single<MutableSet<TopicPartition>>

Get the set of partitions currently assigned to this consumer.

rxBeginningOffsets

open fun rxBeginningOffsets(topicPartition: TopicPartition): Single<Long>

Get the first offset for the given partitions.

rxClose

open fun rxClose(): Completable

Close the consumer

rxCommit

open fun rxCommit(): Completable

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

rxCommitted

open fun rxCommitted(topicPartition: TopicPartition): Single<OffsetAndMetadata>

Get the last committed offset for the given partition (whether the commit happened by this process or another).

rxEndOffsets

open fun rxEndOffsets(topicPartition: TopicPartition): Single<Long>

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.

rxOffsetsForTimes

open fun rxOffsetsForTimes(topicPartition: TopicPartition, timestamp: Long): Single<OffsetAndTimestamp>

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

rxPartitionsFor

open fun rxPartitionsFor(topic: String): Single<MutableList<PartitionInfo>>

Get metadata about the partitions for a given topic.

rxPause

open fun rxPause(topicPartition: TopicPartition): Completable

Suspend fetching from the requested partition.

open fun rxPause(topicPartitions: MutableSet<TopicPartition>): Completable

Suspend fetching from the requested partitions.

rxPaused

open fun rxPaused(): Single<MutableSet<TopicPartition>>

Get the set of partitions that were previously paused by a call to pause(Set).

rxPosition

open fun rxPosition(partition: TopicPartition): Single<Long>

Get the offset of the next record that will be fetched (if a record with that offset exists).

rxResume

open fun rxResume(topicPartition: TopicPartition): Completable

Resume specified partition which have been paused with pause.

open fun rxResume(topicPartitions: MutableSet<TopicPartition>): Completable

Resume specified partitions which have been paused with pause.

rxSeek

open fun rxSeek(topicPartition: TopicPartition, offset: Long): Completable

Overrides the fetch offsets that the consumer will use on the next poll.

rxSeekToBeginning

open fun rxSeekToBeginning(topicPartition: TopicPartition): Completable

Seek to the first offset for each of the given partition.

open fun rxSeekToBeginning(topicPartitions: MutableSet<TopicPartition>): Completable

Seek to the first offset for each of the given partitions.

rxSeekToEnd

open fun rxSeekToEnd(topicPartition: TopicPartition): Completable

Seek to the last offset for each of the given partition.

open fun rxSeekToEnd(topicPartitions: MutableSet<TopicPartition>): Completable

Seek to the last offset for each of the given partitions.

rxSubscribe

open fun rxSubscribe(topic: String): Completable

Subscribe to the given topic to get dynamically assigned partitions.

open fun rxSubscribe(topics: MutableSet<String>): Completable

Subscribe to the given list of topics to get dynamically assigned partitions.

rxSubscription

open fun rxSubscription(): Single<MutableSet<String>>

Get the current subscription.

rxUnsubscribe

open fun rxUnsubscribe(): Completable

Unsubscribe from topics currently subscribed with subscribe.

seek

open fun seek(topicPartition: TopicPartition, offset: Long): KafkaConsumer<K, V>
open fun seek(topicPartition: TopicPartition, offset: Long, completionHandler: Handler<AsyncResult<Void>>): KafkaConsumer<K, V>

Overrides the fetch offsets that the consumer will use on the next poll.

seekToBeginning

open fun seekToBeginning(topicPartition: TopicPartition): KafkaConsumer<K, V>
open fun seekToBeginning(topicPartition: TopicPartition, completionHandler: Handler<AsyncResult<Void>>): KafkaConsumer<K, V>

Seek to the first offset for each of the given partition.

open fun seekToBeginning(topicPartitions: MutableSet<TopicPartition>): KafkaConsumer<K, V>
open fun seekToBeginning(topicPartitions: MutableSet<TopicPartition>, completionHandler: Handler<AsyncResult<Void>>): KafkaConsumer<K, V>

Seek to the first offset for each of the given partitions.

seekToEnd

open fun seekToEnd(topicPartition: TopicPartition): KafkaConsumer<K, V>
open fun seekToEnd(topicPartition: TopicPartition, completionHandler: Handler<AsyncResult<Void>>): KafkaConsumer<K, V>

Seek to the last offset for each of the given partition.

open fun seekToEnd(topicPartitions: MutableSet<TopicPartition>): KafkaConsumer<K, V>
open fun seekToEnd(topicPartitions: MutableSet<TopicPartition>, completionHandler: Handler<AsyncResult<Void>>): KafkaConsumer<K, V>

Seek to the last offset for each of the given partitions.

subscribe

open fun subscribe(topic: String): KafkaConsumer<K, V>
open fun subscribe(topic: String, completionHandler: Handler<AsyncResult<Void>>): KafkaConsumer<K, V>

Subscribe to the given topic to get dynamically assigned partitions.

open fun subscribe(topics: MutableSet<String>): KafkaConsumer<K, V>
open fun subscribe(topics: MutableSet<String>, completionHandler: Handler<AsyncResult<Void>>): KafkaConsumer<K, V>

Subscribe to the given list of topics to get dynamically assigned partitions.

subscription

open fun subscription(handler: Handler<AsyncResult<MutableSet<String>>>): KafkaConsumer<K, V>

Get the current subscription.

toFlowable

open fun toFlowable(): Flowable<KafkaConsumerRecord<K, V>>

toObservable

open fun toObservable(): Observable<KafkaConsumerRecord<K, V>>

toString

open fun toString(): String

unsubscribe

open fun unsubscribe(): KafkaConsumer<K, V>
open fun unsubscribe(completionHandler: Handler<AsyncResult<Void>>): KafkaConsumer<K, V>

Unsubscribe from topics currently subscribed with subscribe.