Class KafkaConsumer<K,V>
- java.lang.Object
-
- io.vertx.reactivex.kafka.client.consumer.KafkaConsumer<K,V>
-
- All Implemented Interfaces:
ReadStream<KafkaConsumerRecord<K,V>>,StreamBase
public class KafkaConsumer<K,V> extends Object implements ReadStream<KafkaConsumerRecord<K,V>>
Vert.x Kafka consumer.You receive Kafka records by providing a
handler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecord<K, V>>). As messages arrive the handler will be called with the records.The
pause()andresume()provides global control over reading the records from the consumer.The
NOTE: This class has been automatically generated from thepause()andresume()provides finer grained control over reading records for specific Topic/Partition, these are Kafka's specific operations.originalnon RX-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<KafkaConsumer>__TYPE_ARGTypeArg<K>__typeArg_0TypeArg<V>__typeArg_1
-
Constructor Summary
Constructors Constructor Description KafkaConsumer(KafkaConsumer delegate)KafkaConsumer(Object delegate, TypeArg<K> typeArg_0, TypeArg<V> typeArg_1)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description KafkaConsumer<K,V>assign(TopicPartition topicPartition)Manually assign a partition to this consumer.KafkaConsumer<K,V>assign(TopicPartition topicPartition, Handler<AsyncResult<Void>> completionHandler)Manually assign a partition to this consumer.KafkaConsumer<K,V>assign(Set<TopicPartition> topicPartitions)Manually assign a list of partition to this consumer.KafkaConsumer<K,V>assign(Set<TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)Manually assign a list of partition to this consumer.KafkaConsumer<K,V>assignment()Get the set of partitions currently assigned to this consumer.KafkaConsumer<K,V>assignment(Handler<AsyncResult<Set<TopicPartition>>> handler)Get the set of partitions currently assigned to this consumer.KafkaConsumer<K,V>batchHandler(Handler<KafkaConsumerRecords<K,V>> handler)Set the handler to be used when batches of messages are fetched from the Kafka server.voidbeginningOffsets(TopicPartition topicPartition)Get the first offset for the given partitions.voidbeginningOffsets(TopicPartition topicPartition, Handler<AsyncResult<Long>> handler)Get the first offset for the given partitions.voidclose()Close the consumervoidclose(Handler<AsyncResult<Void>> completionHandler)Close the consumervoidcommit()Commit current offsets for all the subscribed list of topics and partition.voidcommit(Handler<AsyncResult<Void>> completionHandler)Commit current offsets for all the subscribed list of topics and partition.voidcommitted(TopicPartition topicPartition)Get the last committed offset for the given partition (whether the commit happened by this process or another).voidcommitted(TopicPartition topicPartition, Handler<AsyncResult<OffsetAndMetadata>> handler)Get the last committed offset for the given partition (whether the commit happened by this process or another).static <K,V>
KafkaConsumer<K,V>create(Vertx vertx, KafkaClientOptions options)Create a new KafkaConsumer instancestatic <K,V>
KafkaConsumer<K,V>create(Vertx vertx, KafkaClientOptions options, Class<K> keyType, Class<V> valueType)Create a new KafkaConsumer instancestatic <K,V>
KafkaConsumer<K,V>create(Vertx vertx, Map<String,String> config)Create a new KafkaConsumer instancestatic <K,V>
KafkaConsumer<K,V>create(Vertx vertx, Map<String,String> config, Class<K> keyType, Class<V> valueType)Create a new KafkaConsumer instancelongdemand()Returns the current demand.KafkaConsumer<K,V>endHandler(Handler<Void> endHandler)Set an end handler.voidendOffsets(TopicPartition topicPartition)Get the last offset for the given partition.voidendOffsets(TopicPartition topicPartition, Handler<AsyncResult<Long>> handler)Get the last offset for the given partition.booleanequals(Object o)KafkaConsumer<K,V>exceptionHandler(Handler<Throwable> handler)Set an exception handler on the read stream.KafkaConsumer<K,V>fetch(long amount)Fetch the specifiedamountof elements.KafkaConsumergetDelegate()KafkaConsumer<K,V>handler(Handler<KafkaConsumerRecord<K,V>> handler)Set a data handler.inthashCode()static <K,V>
KafkaConsumer<K,V>newInstance(KafkaConsumer arg)static <K,V>
KafkaConsumer<K,V>newInstance(KafkaConsumer arg, TypeArg<K> __typeArg_K, TypeArg<V> __typeArg_V)voidoffsetsForTimes(TopicPartition topicPartition, Long timestamp)Look up the offset for the given partition by timestamp.voidoffsetsForTimes(TopicPartition topicPartition, Long timestamp, Handler<AsyncResult<OffsetAndTimestamp>> handler)Look up the offset for the given partition by timestamp.KafkaConsumer<K,V>partitionsAssignedHandler(Handler<Set<TopicPartition>> handler)Set the handler called when topic partitions are assigned to the consumerKafkaConsumer<K,V>partitionsFor(String topic)Get metadata about the partitions for a given topic.KafkaConsumer<K,V>partitionsFor(String topic, Handler<AsyncResult<List<PartitionInfo>>> handler)Get metadata about the partitions for a given topic.KafkaConsumer<K,V>partitionsRevokedHandler(Handler<Set<TopicPartition>> handler)Set the handler called when topic partitions are revoked to the consumerKafkaConsumer<K,V>pause()Pause theReadStream, it sets the buffer infetchmode and clears the actual demand.KafkaConsumer<K,V>pause(TopicPartition topicPartition)Suspend fetching from the requested partition.KafkaConsumer<K,V>pause(TopicPartition topicPartition, Handler<AsyncResult<Void>> completionHandler)Suspend fetching from the requested partition.KafkaConsumer<K,V>pause(Set<TopicPartition> topicPartitions)Suspend fetching from the requested partitions.KafkaConsumer<K,V>pause(Set<TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)Suspend fetching from the requested partitions.voidpaused()Get the set of partitions that were previously paused by a call to pause(Set).voidpaused(Handler<AsyncResult<Set<TopicPartition>>> handler)Get the set of partitions that were previously paused by a call to pause(Set).Pipe<KafkaConsumerRecord<K,V>>pipe()Pause this stream and return a to transfer the elements of this stream to a destination .voidpipeTo(WriteStream<KafkaConsumerRecord<K,V>> dst)Pipe thisReadStreamto theWriteStream.voidpipeTo(WriteStream<KafkaConsumerRecord<K,V>> dst, Handler<AsyncResult<Void>> handler)Pipe thisReadStreamto theWriteStream.voidpoll(Duration timeout)Executes a poll for getting messages from Kafka.voidpoll(Duration timeout, Handler<AsyncResult<KafkaConsumerRecords<K,V>>> handler)Executes a poll for getting messages from Kafka.KafkaConsumer<K,V>pollTimeout(Duration timeout)Sets the poll timeout for the underlying native Kafka Consumer.voidposition(TopicPartition partition)Get the offset of the next record that will be fetched (if a record with that offset exists).voidposition(TopicPartition partition, Handler<AsyncResult<Long>> handler)Get the offset of the next record that will be fetched (if a record with that offset exists).KafkaConsumer<K,V>resume()Resume reading, and sets the buffer inflowingmode.KafkaConsumer<K,V>resume(TopicPartition topicPartition)Resume specified partition which have been paused with pause.KafkaConsumer<K,V>resume(TopicPartition topicPartition, Handler<AsyncResult<Void>> completionHandler)Resume specified partition which have been paused with pause.KafkaConsumer<K,V>resume(Set<TopicPartition> topicPartitions)Resume specified partitions which have been paused with pause.KafkaConsumer<K,V>resume(Set<TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)Resume specified partitions which have been paused with pause.io.reactivex.CompletablerxAssign(TopicPartition topicPartition)Manually assign a partition to this consumer.io.reactivex.CompletablerxAssign(Set<TopicPartition> topicPartitions)Manually assign a list of partition to this consumer.io.reactivex.Single<Set<TopicPartition>>rxAssignment()Get the set of partitions currently assigned to this consumer.io.reactivex.Single<Long>rxBeginningOffsets(TopicPartition topicPartition)Get the first offset for the given partitions.io.reactivex.CompletablerxClose()Close the consumerio.reactivex.CompletablerxCommit()Commit current offsets for all the subscribed list of topics and partition.io.reactivex.Single<OffsetAndMetadata>rxCommitted(TopicPartition topicPartition)Get the last committed offset for the given partition (whether the commit happened by this process or another).io.reactivex.Single<Long>rxEndOffsets(TopicPartition topicPartition)Get the last offset for the given partition.io.reactivex.Single<OffsetAndTimestamp>rxOffsetsForTimes(TopicPartition topicPartition, Long timestamp)Look up the offset for the given partition by timestamp.io.reactivex.Single<List<PartitionInfo>>rxPartitionsFor(String topic)Get metadata about the partitions for a given topic.io.reactivex.CompletablerxPause(TopicPartition topicPartition)Suspend fetching from the requested partition.io.reactivex.CompletablerxPause(Set<TopicPartition> topicPartitions)Suspend fetching from the requested partitions.io.reactivex.Single<Set<TopicPartition>>rxPaused()Get the set of partitions that were previously paused by a call to pause(Set).io.reactivex.CompletablerxPipeTo(WriteStream<KafkaConsumerRecord<K,V>> dst)Pipe thisReadStreamto theWriteStream.io.reactivex.Single<KafkaConsumerRecords<K,V>>rxPoll(Duration timeout)Executes a poll for getting messages from Kafka.io.reactivex.Single<Long>rxPosition(TopicPartition partition)Get the offset of the next record that will be fetched (if a record with that offset exists).io.reactivex.CompletablerxResume(TopicPartition topicPartition)Resume specified partition which have been paused with pause.io.reactivex.CompletablerxResume(Set<TopicPartition> topicPartitions)Resume specified partitions which have been paused with pause.io.reactivex.CompletablerxSeek(TopicPartition topicPartition, long offset)Overrides the fetch offsets that the consumer will use on the next poll.io.reactivex.CompletablerxSeekToBeginning(TopicPartition topicPartition)Seek to the first offset for each of the given partition.io.reactivex.CompletablerxSeekToBeginning(Set<TopicPartition> topicPartitions)Seek to the first offset for each of the given partitions.io.reactivex.CompletablerxSeekToEnd(TopicPartition topicPartition)Seek to the last offset for each of the given partition.io.reactivex.CompletablerxSeekToEnd(Set<TopicPartition> topicPartitions)Seek to the last offset for each of the given partitions.io.reactivex.CompletablerxSubscribe(String topic)Subscribe to the given topic to get dynamically assigned partitions.io.reactivex.CompletablerxSubscribe(Set<String> topics)Subscribe to the given list of topics to get dynamically assigned partitions.io.reactivex.Single<Set<String>>rxSubscription()Get the current subscription.io.reactivex.CompletablerxUnsubscribe()Unsubscribe from topics currently subscribed with subscribe.KafkaConsumer<K,V>seek(TopicPartition topicPartition, long offset)Overrides the fetch offsets that the consumer will use on the next poll.KafkaConsumer<K,V>seek(TopicPartition topicPartition, long offset, Handler<AsyncResult<Void>> completionHandler)Overrides the fetch offsets that the consumer will use on the next poll.KafkaConsumer<K,V>seekToBeginning(TopicPartition topicPartition)Seek to the first offset for each of the given partition.KafkaConsumer<K,V>seekToBeginning(TopicPartition topicPartition, Handler<AsyncResult<Void>> completionHandler)Seek to the first offset for each of the given partition.KafkaConsumer<K,V>seekToBeginning(Set<TopicPartition> topicPartitions)Seek to the first offset for each of the given partitions.KafkaConsumer<K,V>seekToBeginning(Set<TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)Seek to the first offset for each of the given partitions.KafkaConsumer<K,V>seekToEnd(TopicPartition topicPartition)Seek to the last offset for each of the given partition.KafkaConsumer<K,V>seekToEnd(TopicPartition topicPartition, Handler<AsyncResult<Void>> completionHandler)Seek to the last offset for each of the given partition.KafkaConsumer<K,V>seekToEnd(Set<TopicPartition> topicPartitions)Seek to the last offset for each of the given partitions.KafkaConsumer<K,V>seekToEnd(Set<TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)Seek to the last offset for each of the given partitions.KafkaConsumer<K,V>subscribe(String topic)Subscribe to the given topic to get dynamically assigned partitions.KafkaConsumer<K,V>subscribe(String topic, Handler<AsyncResult<Void>> completionHandler)Subscribe to the given topic to get dynamically assigned partitions.KafkaConsumer<K,V>subscribe(Set<String> topics)Subscribe to the given list of topics to get dynamically assigned partitions.KafkaConsumer<K,V>subscribe(Set<String> topics, Handler<AsyncResult<Void>> completionHandler)Subscribe to the given list of topics to get dynamically assigned partitions.KafkaConsumer<K,V>subscription()Get the current subscription.KafkaConsumer<K,V>subscription(Handler<AsyncResult<Set<String>>> handler)Get the current subscription.io.reactivex.Flowable<KafkaConsumerRecord<K,V>>toFlowable()io.reactivex.Observable<KafkaConsumerRecord<K,V>>toObservable()StringtoString()KafkaConsumer<K,V>unsubscribe()Unsubscribe from topics currently subscribed with subscribe.KafkaConsumer<K,V>unsubscribe(Handler<AsyncResult<Void>> completionHandler)Unsubscribe from topics currently subscribed with subscribe.
-
-
-
Method Detail
-
getDelegate
public KafkaConsumer getDelegate()
- Specified by:
getDelegatein interfaceReadStream<K>- Specified by:
getDelegatein interfaceStreamBase
-
toObservable
public io.reactivex.Observable<KafkaConsumerRecord<K,V>> toObservable()
- Specified by:
toObservablein interfaceReadStream<K>
-
toFlowable
public io.reactivex.Flowable<KafkaConsumerRecord<K,V>> toFlowable()
- Specified by:
toFlowablein interfaceReadStream<K>
-
pipe
public Pipe<KafkaConsumerRecord<K,V>> pipe()
Pause this stream and return a to transfer the elements of this stream to a destination . The stream will be resumed when the pipe will be wired to aWriteStream.- Specified by:
pipein interfaceReadStream<K>- Returns:
- a pipe
-
pipeTo
public void pipeTo(WriteStream<KafkaConsumerRecord<K,V>> dst, Handler<AsyncResult<Void>> handler)
Pipe thisReadStreamto theWriteStream.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
handlerwill be called with the result.- Specified by:
pipeToin interfaceReadStream<K>- Parameters:
dst- the destination write streamhandler-
-
pipeTo
public void pipeTo(WriteStream<KafkaConsumerRecord<K,V>> dst)
Pipe thisReadStreamto theWriteStream.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
handlerwill be called with the result.- Specified by:
pipeToin interfaceReadStream<K>- Parameters:
dst- the destination write stream
-
rxPipeTo
public io.reactivex.Completable rxPipeTo(WriteStream<KafkaConsumerRecord<K,V>> dst)
Pipe thisReadStreamto theWriteStream.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
handlerwill be called with the result.- Specified by:
rxPipeToin interfaceReadStream<K>- Parameters:
dst- the destination write stream- Returns:
-
create
public static <K,V> KafkaConsumer<K,V> create(Vertx vertx, Map<String,String> config)
Create a new KafkaConsumer instance- Parameters:
vertx- Vert.x instance to useconfig- 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)
Create a new KafkaConsumer instance- Parameters:
vertx- Vert.x instance to useconfig- Kafka consumer configurationkeyType- class type for the key deserializationvalueType- class type for the value deserialization- Returns:
- an instance of the KafkaConsumer
-
create
public static <K,V> KafkaConsumer<K,V> create(Vertx vertx, KafkaClientOptions options)
Create a new KafkaConsumer instance- Parameters:
vertx- Vert.x instance to useoptions- Kafka consumer options- Returns:
- an instance of the KafkaConsumer
-
create
public static <K,V> KafkaConsumer<K,V> create(Vertx vertx, KafkaClientOptions options, Class<K> keyType, Class<V> valueType)
Create a new KafkaConsumer instance- Parameters:
vertx- Vert.x instance to useoptions- Kafka consumer optionskeyType- class type for the key deserializationvalueType- class type for the value deserialization- Returns:
- an instance of the KafkaConsumer
-
exceptionHandler
public KafkaConsumer<K,V> exceptionHandler(Handler<Throwable> handler)
Description copied from interface:ReadStreamSet an exception handler on the read stream.- Specified by:
exceptionHandlerin interfaceReadStream<K>- Specified by:
exceptionHandlerin interfaceStreamBase- Parameters:
handler- the exception handler- Returns:
- a reference to this, so the API can be used fluently
-
handler
public KafkaConsumer<K,V> handler(Handler<KafkaConsumerRecord<K,V>> handler)
Description copied from interface:ReadStreamSet a data handler. As data is read, the handler will be called with the data.- Specified by:
handlerin interfaceReadStream<K>- Returns:
- a reference to this, so the API can be used fluently
-
pause
public KafkaConsumer<K,V> pause()
Description copied from interface:ReadStreamPause theReadStream, it sets the buffer infetchmode and clears the actual demand.While it's paused, no data will be sent to the data
handler.- Specified by:
pausein interfaceReadStream<K>- Returns:
- a reference to this, so the API can be used fluently
-
resume
public KafkaConsumer<K,V> resume()
Description copied from interface:ReadStreamResume reading, and sets the buffer inflowingmode. If theReadStreamhas been paused, reading will recommence on it.- Specified by:
resumein interfaceReadStream<K>- Returns:
- a reference to this, so the API can be used fluently
-
fetch
public KafkaConsumer<K,V> fetch(long amount)
Description copied from interface:ReadStreamFetch the specifiedamountof elements. If theReadStreamhas been paused, reading will recommence with the specifiedamountof items, otherwise the specifiedamountwill be added to the current stream demand.- Specified by:
fetchin interfaceReadStream<K>- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
public KafkaConsumer<K,V> endHandler(Handler<Void> endHandler)
Description copied from interface:ReadStreamSet an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.- Specified by:
endHandlerin interfaceReadStream<K>- Returns:
- a reference to this, so the API can be used fluently
-
demand
public long demand()
Returns the current demand.-
If the stream is in flowing mode will return
- If the stream is in fetch mode, will return the current number of elements still to be delivered or 0 if paused.
Long.- Returns:
- current demand
-
subscribe
public KafkaConsumer<K,V> subscribe(String topic, Handler<AsyncResult<Void>> completionHandler)
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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new topic.- Parameters:
topic- topic to subscribe tocompletionHandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
subscribe
public KafkaConsumer<K,V> 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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new topic.- Parameters:
topic- topic to subscribe to- Returns:
- current KafkaConsumer instance
-
rxSubscribe
public io.reactivex.Completable rxSubscribe(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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new topic.- Parameters:
topic- topic to subscribe to- Returns:
- current KafkaConsumer instance
-
subscribe
public KafkaConsumer<K,V> subscribe(Set<String> topics, Handler<AsyncResult<Void>> completionHandler)
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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new set of topics.- Parameters:
topics- topics to subscribe tocompletionHandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
subscribe
public KafkaConsumer<K,V> 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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new set of topics.- Parameters:
topics- topics to subscribe to- Returns:
- current KafkaConsumer instance
-
rxSubscribe
public io.reactivex.Completable rxSubscribe(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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new set of topics.- Parameters:
topics- topics to subscribe to- Returns:
- current KafkaConsumer instance
-
assign
public KafkaConsumer<K,V> assign(TopicPartition topicPartition, Handler<AsyncResult<Void>> completionHandler)
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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new partition.- Parameters:
topicPartition- partition which want assignedcompletionHandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
assign
public KafkaConsumer<K,V> assign(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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new partition.- Parameters:
topicPartition- partition which want assigned- Returns:
- current KafkaConsumer instance
-
rxAssign
public io.reactivex.Completable rxAssign(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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new partition.- Parameters:
topicPartition- partition which want assigned- Returns:
- current KafkaConsumer instance
-
assign
public KafkaConsumer<K,V> assign(Set<TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)
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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new set of partitions.- Parameters:
topicPartitions- partitions which want assignedcompletionHandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
assign
public KafkaConsumer<K,V> assign(Set<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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new set of partitions.- Parameters:
topicPartitions- partitions which want assigned- Returns:
- current KafkaConsumer instance
-
rxAssign
public io.reactivex.Completable rxAssign(Set<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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new set of partitions.- Parameters:
topicPartitions- partitions which want assigned- Returns:
- current KafkaConsumer instance
-
assignment
public KafkaConsumer<K,V> assignment(Handler<AsyncResult<Set<TopicPartition>>> handler)
Get the set of partitions currently assigned to this consumer.- Parameters:
handler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
assignment
public KafkaConsumer<K,V> assignment()
Get the set of partitions currently assigned to this consumer.- Returns:
- current KafkaConsumer instance
-
rxAssignment
public io.reactivex.Single<Set<TopicPartition>> rxAssignment()
Get the set of partitions currently assigned to this consumer.- Returns:
- current KafkaConsumer instance
-
unsubscribe
public KafkaConsumer<K,V> unsubscribe(Handler<AsyncResult<Void>> completionHandler)
Unsubscribe from topics currently subscribed with subscribe.- Parameters:
completionHandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
unsubscribe
public KafkaConsumer<K,V> unsubscribe()
Unsubscribe from topics currently subscribed with subscribe.- Returns:
- current KafkaConsumer instance
-
rxUnsubscribe
public io.reactivex.Completable rxUnsubscribe()
Unsubscribe from topics currently subscribed with subscribe.- Returns:
- current KafkaConsumer instance
-
subscription
public KafkaConsumer<K,V> subscription(Handler<AsyncResult<Set<String>>> handler)
Get the current subscription.- Parameters:
handler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
subscription
public KafkaConsumer<K,V> subscription()
Get the current subscription.- Returns:
- current KafkaConsumer instance
-
rxSubscription
public io.reactivex.Single<Set<String>> rxSubscription()
Get the current subscription.- Returns:
- current KafkaConsumer instance
-
pause
public KafkaConsumer<K,V> pause(TopicPartition topicPartition, Handler<AsyncResult<Void>> completionHandler)
Suspend fetching from the requested partition.Due to internal buffering of messages, the will continue to observe messages from the given
topicPartitionuntil some time after the givencompletionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will not see messages from the giventopicPartition.- Parameters:
topicPartition- topic partition from which suspend fetchingcompletionHandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
pause
public KafkaConsumer<K,V> pause(TopicPartition topicPartition)
Suspend fetching from the requested partition.Due to internal buffering of messages, the will continue to observe messages from the given
topicPartitionuntil some time after the givencompletionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will not see messages from the giventopicPartition.- Parameters:
topicPartition- topic partition from which suspend fetching- Returns:
- current KafkaConsumer instance
-
rxPause
public io.reactivex.Completable rxPause(TopicPartition topicPartition)
Suspend fetching from the requested partition.Due to internal buffering of messages, the will continue to observe messages from the given
topicPartitionuntil some time after the givencompletionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will not see messages from the giventopicPartition.- Parameters:
topicPartition- topic partition from which suspend fetching- Returns:
- current KafkaConsumer instance
-
pause
public KafkaConsumer<K,V> pause(Set<TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)
Suspend fetching from the requested partitions.Due to internal buffering of messages, the will continue to observe messages from the given
topicPartitionsuntil some time after the givencompletionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will not see messages from the giventopicPartitions.- Parameters:
topicPartitions- topic partition from which suspend fetchingcompletionHandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
pause
public KafkaConsumer<K,V> pause(Set<TopicPartition> topicPartitions)
Suspend fetching from the requested partitions.Due to internal buffering of messages, the will continue to observe messages from the given
topicPartitionsuntil some time after the givencompletionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will not see messages from the giventopicPartitions.- Parameters:
topicPartitions- topic partition from which suspend fetching- Returns:
- current KafkaConsumer instance
-
rxPause
public io.reactivex.Completable rxPause(Set<TopicPartition> topicPartitions)
Suspend fetching from the requested partitions.Due to internal buffering of messages, the will continue to observe messages from the given
topicPartitionsuntil some time after the givencompletionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will not see messages from the giventopicPartitions.- Parameters:
topicPartitions- topic partition from which suspend fetching- Returns:
- current KafkaConsumer instance
-
paused
public void paused(Handler<AsyncResult<Set<TopicPartition>>> handler)
Get the set of partitions that were previously paused by a call to pause(Set).- Parameters:
handler- handler called on operation completed
-
paused
public void paused()
Get the set of partitions that were previously paused by a call to pause(Set).
-
rxPaused
public io.reactivex.Single<Set<TopicPartition>> rxPaused()
Get the set of partitions that were previously paused by a call to pause(Set).- Returns:
-
resume
public KafkaConsumer<K,V> resume(TopicPartition topicPartition, Handler<AsyncResult<Void>> completionHandler)
Resume specified partition which have been paused with pause.- Parameters:
topicPartition- topic partition from which resume fetchingcompletionHandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
resume
public KafkaConsumer<K,V> resume(TopicPartition topicPartition)
Resume specified partition which have been paused with pause.- Parameters:
topicPartition- topic partition from which resume fetching- Returns:
- current KafkaConsumer instance
-
rxResume
public io.reactivex.Completable rxResume(TopicPartition topicPartition)
Resume specified partition which have been paused with pause.- Parameters:
topicPartition- topic partition from which resume fetching- Returns:
- current KafkaConsumer instance
-
resume
public KafkaConsumer<K,V> resume(Set<TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)
Resume specified partitions which have been paused with pause.- Parameters:
topicPartitions- topic partition from which resume fetchingcompletionHandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
resume
public KafkaConsumer<K,V> resume(Set<TopicPartition> topicPartitions)
Resume specified partitions which have been paused with pause.- Parameters:
topicPartitions- topic partition from which resume fetching- Returns:
- current KafkaConsumer instance
-
rxResume
public io.reactivex.Completable rxResume(Set<TopicPartition> topicPartitions)
Resume specified partitions which have been paused with pause.- Parameters:
topicPartitions- topic partition from which resume fetching- Returns:
- current KafkaConsumer instance
-
partitionsRevokedHandler
public KafkaConsumer<K,V> partitionsRevokedHandler(Handler<Set<TopicPartition>> handler)
Set the handler called when topic partitions are revoked to the consumer- Parameters:
handler- handler called on revoked topic partitions- Returns:
- current KafkaConsumer instance
-
partitionsAssignedHandler
public KafkaConsumer<K,V> partitionsAssignedHandler(Handler<Set<TopicPartition>> handler)
Set the handler called when topic partitions are assigned to the consumer- Parameters:
handler- handler called on assigned topic partitions- Returns:
- current KafkaConsumer instance
-
seek
public KafkaConsumer<K,V> seek(TopicPartition topicPartition, long offset, Handler<AsyncResult<Void>> completionHandler)
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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartition- topic partition for which seekoffset- offset to seek inside the topic partitioncompletionHandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
seek
public KafkaConsumer<K,V> seek(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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartition- topic partition for which seekoffset- offset to seek inside the topic partition- Returns:
- current KafkaConsumer instance
-
rxSeek
public io.reactivex.Completable rxSeek(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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartition- topic partition for which seekoffset- offset to seek inside the topic partition- Returns:
- current KafkaConsumer instance
-
seekToBeginning
public KafkaConsumer<K,V> seekToBeginning(TopicPartition topicPartition, Handler<AsyncResult<Void>> completionHandler)
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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartition- topic partition for which seekcompletionHandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
seekToBeginning
public KafkaConsumer<K,V> seekToBeginning(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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartition- topic partition for which seek- Returns:
- current KafkaConsumer instance
-
rxSeekToBeginning
public io.reactivex.Completable rxSeekToBeginning(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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartition- topic partition for which seek- Returns:
- current KafkaConsumer instance
-
seekToBeginning
public KafkaConsumer<K,V> seekToBeginning(Set<TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)
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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartitions- topic partition for which seekcompletionHandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
seekToBeginning
public KafkaConsumer<K,V> seekToBeginning(Set<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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartitions- topic partition for which seek- Returns:
- current KafkaConsumer instance
-
rxSeekToBeginning
public io.reactivex.Completable rxSeekToBeginning(Set<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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartitions- topic partition for which seek- Returns:
- current KafkaConsumer instance
-
seekToEnd
public KafkaConsumer<K,V> seekToEnd(TopicPartition topicPartition, Handler<AsyncResult<Void>> completionHandler)
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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartition- topic partition for which seekcompletionHandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
seekToEnd
public KafkaConsumer<K,V> seekToEnd(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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartition- topic partition for which seek- Returns:
- current KafkaConsumer instance
-
rxSeekToEnd
public io.reactivex.Completable rxSeekToEnd(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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartition- topic partition for which seek- Returns:
- current KafkaConsumer instance
-
seekToEnd
public KafkaConsumer<K,V> seekToEnd(Set<TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)
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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartitions- topic partition for which seekcompletionHandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
seekToEnd
public KafkaConsumer<K,V> seekToEnd(Set<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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartitions- topic partition for which seek- Returns:
- current KafkaConsumer instance
-
rxSeekToEnd
public io.reactivex.Completable rxSeekToEnd(Set<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
completionHandleris called. In contrast, the once the givencompletionHandleris called thebatchHandler(io.vertx.core.Handler<io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords<K, V>>)will only see messages consistent with the new offset.- Parameters:
topicPartitions- topic partition for which seek- Returns:
- current KafkaConsumer instance
-
commit
public void commit(Handler<AsyncResult<Void>> completionHandler)
Commit current offsets for all the subscribed list of topics and partition.- Parameters:
completionHandler- handler called on operation completed
-
commit
public void commit()
Commit current offsets for all the subscribed list of topics and partition.
-
rxCommit
public io.reactivex.Completable rxCommit()
Commit current offsets for all the subscribed list of topics and partition.- Returns:
-
committed
public void committed(TopicPartition topicPartition, Handler<AsyncResult<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 offsethandler- handler called on operation completed
-
committed
public void committed(TopicPartition topicPartition)
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
-
rxCommitted
public io.reactivex.Single<OffsetAndMetadata> rxCommitted(TopicPartition topicPartition)
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- Returns:
-
partitionsFor
public KafkaConsumer<K,V> partitionsFor(String topic, Handler<AsyncResult<List<PartitionInfo>>> handler)
Get metadata about the partitions for a given topic.- Parameters:
topic- topic partition for which getting partitions infohandler- handler called on operation completed- Returns:
- current KafkaConsumer instance
-
partitionsFor
public KafkaConsumer<K,V> partitionsFor(String topic)
Get metadata about the partitions for a given topic.- Parameters:
topic- topic partition for which getting partitions info- Returns:
- current KafkaConsumer instance
-
rxPartitionsFor
public io.reactivex.Single<List<PartitionInfo>> rxPartitionsFor(String topic)
Get metadata about the partitions for a given topic.- Parameters:
topic- topic partition for which getting partitions info- Returns:
- current KafkaConsumer instance
-
batchHandler
public KafkaConsumer<K,V> batchHandler(Handler<KafkaConsumerRecords<K,V>> handler)
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#handler(Handler) record handler.- Parameters:
handler- handler called when batches of messages are fetched- Returns:
- current KafkaConsumer instance
-
close
public void close(Handler<AsyncResult<Void>> completionHandler)
Close the consumer- Parameters:
completionHandler- handler called on operation completed
-
close
public void close()
Close the consumer
-
rxClose
public io.reactivex.Completable rxClose()
Close the consumer- Returns:
-
position
public void position(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 forhandler- handler called on operation completed
-
position
public void position(TopicPartition partition)
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
-
rxPosition
public io.reactivex.Single<Long> rxPosition(TopicPartition partition)
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- Returns:
-
offsetsForTimes
public void offsetsForTimes(TopicPartition topicPartition, Long timestamp, Handler<AsyncResult<OffsetAndTimestamp>> handler)
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- Parameters:
topicPartition- TopicPartition to query.timestamp- Timestamp to be used in the query.handler- handler called on operation completed
-
offsetsForTimes
public void offsetsForTimes(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- Parameters:
topicPartition- TopicPartition to query.timestamp- Timestamp to be used in the query.
-
rxOffsetsForTimes
public io.reactivex.Single<OffsetAndTimestamp> rxOffsetsForTimes(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- Parameters:
topicPartition- TopicPartition to query.timestamp- Timestamp to be used in the query.- Returns:
-
beginningOffsets
public void beginningOffsets(TopicPartition topicPartition, Handler<AsyncResult<Long>> handler)
Get the first offset for the given partitions.- Parameters:
topicPartition- the partition to get the earliest offset.handler- handler called on operation completed. Returns the earliest available offset for the given partition
-
beginningOffsets
public void beginningOffsets(TopicPartition topicPartition)
Get the first offset for the given partitions.- Parameters:
topicPartition- the partition to get the earliest offset.
-
rxBeginningOffsets
public io.reactivex.Single<Long> rxBeginningOffsets(TopicPartition topicPartition)
Get the first offset for the given partitions.- Parameters:
topicPartition- the partition to get the earliest offset.- Returns:
-
endOffsets
public void endOffsets(TopicPartition topicPartition, Handler<AsyncResult<Long>> handler)
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.- Parameters:
topicPartition- the partition to get the end offset.handler- handler called on operation completed. The end offset for the given partition.
-
endOffsets
public void endOffsets(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.- Parameters:
topicPartition- the partition to get the end offset.
-
rxEndOffsets
public io.reactivex.Single<Long> rxEndOffsets(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.- Parameters:
topicPartition- the partition to get the end offset.- Returns:
-
pollTimeout
public KafkaConsumer<K,V> pollTimeout(Duration timeout)
Sets the poll timeout for the underlying native Kafka Consumer. Defaults to 1000ms. Setting timeout to a lower value results in a more 'responsive' client, because it will block for a shorter period if no data is available in the assigned partition and therefore allows subsequent actions to be executed with a shorter delay. At the same time, the client will poll more frequently and thus will potentially create a higher load on the Kafka Broker.- 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:
-
poll
public void poll(Duration timeout, Handler<AsyncResult<KafkaConsumerRecords<K,V>>> handler)
Executes a poll for getting messages from Kafka.- Parameters:
timeout- The maximum time to block (must not be greater thanLongmilliseconds)handler- handler called after the poll with batch of records (can be empty).
-
poll
public void poll(Duration timeout)
Executes a poll for getting messages from Kafka.- Parameters:
timeout- The maximum time to block (must not be greater thanLongmilliseconds)
-
rxPoll
public io.reactivex.Single<KafkaConsumerRecords<K,V>> rxPoll(Duration timeout)
Executes a poll for getting messages from Kafka.- Parameters:
timeout- The maximum time to block (must not be greater thanLongmilliseconds)- Returns:
-
newInstance
public static <K,V> KafkaConsumer<K,V> newInstance(KafkaConsumer arg)
-
newInstance
public static <K,V> KafkaConsumer<K,V> newInstance(KafkaConsumer arg, TypeArg<K> __typeArg_K, TypeArg<V> __typeArg_V)
-
-