public interface KafkaReadStream<K,V> extends ReadStream<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>
ReadStream
for consuming Kafka ConsumerRecord
.
The pause()
and 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.
Modifier and Type | Method and Description |
---|---|
Future<Void> |
assign(Set<org.apache.kafka.common.TopicPartition> partitions)
Manually assign a set of partitions to this consumer.
|
KafkaReadStream<K,V> |
assign(Set<org.apache.kafka.common.TopicPartition> partitions,
Handler<AsyncResult<Void>> completionHandler)
Manually assign a set of partitions to this consumer.
|
Future<Set<org.apache.kafka.common.TopicPartition>> |
assignment()
Like
assignment(Handler) but returns a Future of the asynchronous result |
KafkaReadStream<K,V> |
assignment(Handler<AsyncResult<Set<org.apache.kafka.common.TopicPartition>>> handler)
Get the set of partitions currently assigned to this consumer.
|
KafkaReadStream<K,V> |
batchHandler(Handler<org.apache.kafka.clients.consumer.ConsumerRecords<K,V>> handler)
Set the handler that will be called when a new batch of records is
returned from Kafka.
|
Future<Map<org.apache.kafka.common.TopicPartition,Long>> |
beginningOffsets(Set<org.apache.kafka.common.TopicPartition> topicPartitions)
Like
beginningOffsets(Set, Handler) but returns a Future of the asynchronous result |
void |
beginningOffsets(Set<org.apache.kafka.common.TopicPartition> topicPartitions,
Handler<AsyncResult<Map<org.apache.kafka.common.TopicPartition,Long>>> handler)
Get the first offset for the given partitions.
|
Future<Long> |
beginningOffsets(org.apache.kafka.common.TopicPartition topicPartition)
Like
beginningOffsets(TopicPartition, Handler) but returns a Future of the asynchronous result |
void |
beginningOffsets(org.apache.kafka.common.TopicPartition topicPartition,
Handler<AsyncResult<Long>> handler)
Get the first offset for the given partition.
|
Future<Void> |
close()
Close the stream
|
void |
close(Handler<AsyncResult<Void>> completionHandler)
Close the stream
|
Future<Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata>> |
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.
|
Future<Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata>> |
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.
|
Future<org.apache.kafka.clients.consumer.OffsetAndMetadata> |
committed(org.apache.kafka.common.TopicPartition topicPartition)
Like
committed(TopicPartition, Handler) but returns a Future of the asynchronous result |
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).
|
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,
KafkaClientOptions options)
Create a new KafkaReadStream instance
|
static <K,V> KafkaReadStream<K,V> |
create(Vertx vertx,
KafkaClientOptions options,
Class<K> keyType,
Class<V> valueType)
Create a new KafkaReadStream instance
|
static <K,V> KafkaReadStream<K,V> |
create(Vertx vertx,
KafkaClientOptions options,
org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer,
org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer)
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,
Map<String,Object> config,
org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer,
org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer)
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
|
static <K,V> KafkaReadStream<K,V> |
create(Vertx vertx,
Properties config,
org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer,
org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer)
Create a new KafkaReadStream instance
|
long |
demand()
Returns the current demand.
|
KafkaReadStream<K,V> |
endHandler(Handler<Void> endHandler)
Set an end handler.
|
Future<Map<org.apache.kafka.common.TopicPartition,Long>> |
endOffsets(Set<org.apache.kafka.common.TopicPartition> topicPartitions)
Like
endOffsets(Set, Handler) but returns a Future of the asynchronous result |
void |
endOffsets(Set<org.apache.kafka.common.TopicPartition> topicPartitions,
Handler<AsyncResult<Map<org.apache.kafka.common.TopicPartition,Long>>> handler)
Get the last offset for the given partitions.
|
Future<Long> |
endOffsets(org.apache.kafka.common.TopicPartition topicPartition)
Like
endOffsets(TopicPartition, Handler) but returns a Future of the asynchronous result |
void |
endOffsets(org.apache.kafka.common.TopicPartition topicPartition,
Handler<AsyncResult<Long>> handler)
Get the last offset for the given partition.
|
KafkaReadStream<K,V> |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.
|
KafkaReadStream<K,V> |
fetch(long amount)
Fetch the specified
amount of elements. |
KafkaReadStream<K,V> |
handler(Handler<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>> handler)
Set a data handler.
|
Future<Map<String,List<org.apache.kafka.common.PartitionInfo>>> |
listTopics()
Like
listTopics(Handler) but returns a Future of the asynchronous result |
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.
|
Future<Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndTimestamp>> |
offsetsForTimes(Map<org.apache.kafka.common.TopicPartition,Long> topicPartitionTimestamps)
Like
offsetsForTimes(Map, Handler) but returns a Future of the asynchronous result |
void |
offsetsForTimes(Map<org.apache.kafka.common.TopicPartition,Long> topicPartitionTimestamps,
Handler<AsyncResult<Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndTimestamp>>> handler)
Look up the offsets for the given partitions by timestamp.
|
Future<org.apache.kafka.clients.consumer.OffsetAndTimestamp> |
offsetsForTimes(org.apache.kafka.common.TopicPartition topicPartition,
long timestamp)
Like
offsetsForTimes(TopicPartition, long, Handler) but returns a Future of the asynchronous result |
void |
offsetsForTimes(org.apache.kafka.common.TopicPartition topicPartition,
long timestamp,
Handler<AsyncResult<org.apache.kafka.clients.consumer.OffsetAndTimestamp>> handler)
* Look up the offset for the given partition by timestamp.
|
KafkaReadStream<K,V> |
partitionsAssignedHandler(Handler<Set<org.apache.kafka.common.TopicPartition>> handler)
Set the handler called when topic partitions are assigned to the consumer
|
Future<List<org.apache.kafka.common.PartitionInfo>> |
partitionsFor(String topic)
Like
partitionsFor(String, Handler) but returns a Future of the asynchronous result |
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()
Pause the
ReadStream , it sets the buffer in fetch mode and clears the actual demand. |
Future<Void> |
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.
|
Future<Set<org.apache.kafka.common.TopicPartition>> |
paused()
Like
paused(Handler) but returns a Future of the asynchronous result |
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) . |
Future<org.apache.kafka.clients.consumer.ConsumerRecords<K,V>> |
poll(java.time.Duration timeout)
Like
poll(Duration, Handler) but returns a Future of the asynchronous result |
void |
poll(java.time.Duration timeout,
Handler<AsyncResult<org.apache.kafka.clients.consumer.ConsumerRecords<K,V>>> handler)
Executes a poll for getting messages from Kafka.
|
KafkaReadStream<K,V> |
pollTimeout(java.time.Duration timeout)
Sets the poll timeout for the underlying native Kafka Consumer.
|
Future<Long> |
position(org.apache.kafka.common.TopicPartition partition)
Like
position(TopicPartition, Handler) but returns a Future of the asynchronous result |
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()
Resume reading, and sets the buffer in
flowing mode. |
Future<Void> |
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.
|
Future<Void> |
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.
|
Future<Void> |
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.
|
Future<Void> |
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.
|
Future<Void> |
subscribe(Pattern pattern)
Subscribe to all topics matching specified pattern to get dynamically assigned partitions.
|
KafkaReadStream<K,V> |
subscribe(Pattern pattern,
Handler<AsyncResult<Void>> completionHandler)
Subscribe to all topics matching specified pattern to get dynamically assigned partitions.
|
Future<Void> |
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.
|
Future<Set<String>> |
subscription()
Like
subscription(Handler) but returns a Future of the asynchronous result |
KafkaReadStream<K,V> |
subscription(Handler<AsyncResult<Set<String>>> handler)
Get the current subscription.
|
Future<Void> |
unsubscribe()
Unsubscribe from topics currently subscribed with subscribe.
|
KafkaReadStream<K,V> |
unsubscribe(Handler<AsyncResult<Void>> completionHandler)
Unsubscribe from topics currently subscribed with subscribe.
|
org.apache.kafka.clients.consumer.Consumer<K,V> |
unwrap() |
pipe, pipeTo, pipeTo
KafkaReadStream<K,V> exceptionHandler(Handler<Throwable> handler)
ReadStream
exceptionHandler
in interface ReadStream<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>
exceptionHandler
in interface StreamBase
handler
- the exception handlerKafkaReadStream<K,V> handler(Handler<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>> handler)
ReadStream
handler
in interface ReadStream<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>
KafkaReadStream<K,V> pause()
ReadStream
ReadStream
, it sets the buffer in fetch
mode and clears the actual demand.
While it's paused, no data will be sent to the data handler
.
pause
in interface ReadStream<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>
KafkaReadStream<K,V> resume()
ReadStream
flowing
mode.
If the ReadStream
has been paused, reading will recommence on it.resume
in interface ReadStream<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>
KafkaReadStream<K,V> fetch(long amount)
ReadStream
amount
of elements. If the ReadStream
has been paused, reading will
recommence with the specified amount
of items, otherwise the specified amount
will
be added to the current stream demand.fetch
in interface ReadStream<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>
KafkaReadStream<K,V> endHandler(Handler<Void> endHandler)
ReadStream
endHandler
in interface ReadStream<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>
long demand()
Long.MAX_VALUE
.
static <K,V> KafkaReadStream<K,V> create(Vertx vertx, Properties config)
vertx
- Vert.x instance to useconfig
- Kafka consumer configurationstatic <K,V> KafkaReadStream<K,V> create(Vertx vertx, Properties config, Class<K> keyType, Class<V> valueType)
vertx
- Vert.x instance to useconfig
- Kafka consumer configurationkeyType
- class type for the key deserializationvalueType
- class type for the value deserializationstatic <K,V> KafkaReadStream<K,V> create(Vertx vertx, Properties config, org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer, org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer)
vertx
- Vert.x instance to useconfig
- Kafka consumer configurationkeyDeserializer
- key deserializervalueDeserializer
- value deserializerstatic <K,V> KafkaReadStream<K,V> create(Vertx vertx, Map<String,Object> config)
vertx
- Vert.x instance to useconfig
- Kafka consumer configurationstatic <K,V> KafkaReadStream<K,V> create(Vertx vertx, Map<String,Object> config, Class<K> keyType, Class<V> valueType)
vertx
- Vert.x instance to useconfig
- Kafka consumer configurationkeyType
- class type for the key deserializationvalueType
- class type for the value deserializationstatic <K,V> KafkaReadStream<K,V> create(Vertx vertx, Map<String,Object> config, org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer, org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer)
vertx
- Vert.x instance to useconfig
- Kafka consumer configurationkeyDeserializer
- key deserializervalueDeserializer
- value deserializerstatic <K,V> KafkaReadStream<K,V> create(Vertx vertx, KafkaClientOptions options)
vertx
- Vert.x instance to useoptions
- Kafka consumer optionsstatic <K,V> KafkaReadStream<K,V> create(Vertx vertx, KafkaClientOptions options, Class<K> keyType, Class<V> valueType)
vertx
- Vert.x instance to useoptions
- Kafka consumer optionskeyType
- class type for the key deserializationvalueType
- class type for the value deserializationstatic <K,V> KafkaReadStream<K,V> create(Vertx vertx, KafkaClientOptions options, org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer, org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer)
vertx
- Vert.x instance to useoptions
- Kafka consumer optionskeyDeserializer
- key deserializervalueDeserializer
- value deserializerstatic <K,V> KafkaReadStream<K,V> create(Vertx vertx, org.apache.kafka.clients.consumer.Consumer<K,V> consumer)
vertx
- Vert.x instance to useconsumer
- native Kafka consumer instancevoid committed(org.apache.kafka.common.TopicPartition topicPartition, Handler<AsyncResult<org.apache.kafka.clients.consumer.OffsetAndMetadata>> handler)
topicPartition
- topic partition for getting last committed offsethandler
- handler called on operation completedFuture<org.apache.kafka.clients.consumer.OffsetAndMetadata> committed(org.apache.kafka.common.TopicPartition topicPartition)
committed(TopicPartition, Handler)
but returns a Future
of the asynchronous resultFuture<Void> pause(Set<org.apache.kafka.common.TopicPartition> topicPartitions)
topicPartitions
- topic partition from which suspend fetchingFuture
completed with the operation resultKafkaReadStream<K,V> pause(Set<org.apache.kafka.common.TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)
Due to internal buffering of messages,
the record handler 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(Handler)
will not see messages
from the given topicPartitions
.
topicPartitions
- topic partition from which suspend fetchingcompletionHandler
- handler called on operation completedvoid paused(Handler<AsyncResult<Set<org.apache.kafka.common.TopicPartition>>> handler)
pause(Set)
.handler
- handler called on operation completedFuture<Set<org.apache.kafka.common.TopicPartition>> paused()
paused(Handler)
but returns a Future
of the asynchronous resultFuture<Void> resume(Set<org.apache.kafka.common.TopicPartition> topicPartitions)
topicPartitions
- topic partition from which resume fetchingFuture
completed with the operation resultKafkaReadStream<K,V> resume(Set<org.apache.kafka.common.TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)
topicPartitions
- topic partition from which resume fetchingcompletionHandler
- handler called on operation completedFuture<Void> seekToEnd(Set<org.apache.kafka.common.TopicPartition> topicPartitions)
topicPartitions
- topic partition for which seekFuture
completed with the operation resultKafkaReadStream<K,V> seekToEnd(Set<org.apache.kafka.common.TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)
Due to internal buffering of messages,
the record handler 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(Handler)
will only see messages
consistent with the new offset.
topicPartitions
- topic partition for which seekcompletionHandler
- handler called on operation completedFuture<Void> seekToBeginning(Set<org.apache.kafka.common.TopicPartition> topicPartitions)
topicPartitions
- topic partition for which seekFuture
completed with the operation resultKafkaReadStream<K,V> seekToBeginning(Set<org.apache.kafka.common.TopicPartition> topicPartitions, Handler<AsyncResult<Void>> completionHandler)
Due to internal buffering of messages,
the record handler 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(Handler)
will only see messages
consistent with the new offset.
topicPartitions
- topic partition for which seekcompletionHandler
- handler called on operation completedFuture<Void> seek(org.apache.kafka.common.TopicPartition topicPartition, long offset)
topicPartition
- topic partition for which seekoffset
- offset to seek inside the topic partitionFuture
completed with the operation resultKafkaReadStream<K,V> seek(org.apache.kafka.common.TopicPartition topicPartition, long offset, Handler<AsyncResult<Void>> completionHandler)
Due to internal buffering of messages,
the record handler 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(Handler)
will only see messages
consistent with the new offset.
topicPartition
- topic partition for which seekoffset
- offset to seek inside the topic partitioncompletionHandler
- handler called on operation completedKafkaReadStream<K,V> partitionsRevokedHandler(Handler<Set<org.apache.kafka.common.TopicPartition>> handler)
handler
- handler called on revoked topic partitionsKafkaReadStream<K,V> partitionsAssignedHandler(Handler<Set<org.apache.kafka.common.TopicPartition>> handler)
handler
- handler called on assigned topic partitionsFuture<Void> subscribe(Set<String> topics)
topics
- topics to subscribe toFuture
completed with the operation resultKafkaReadStream<K,V> subscribe(Set<String> topics, Handler<AsyncResult<Void>> completionHandler)
Due to internal buffering of messages, when changing the subscribed topics
the old set of topics may remain in effect
(as observed by the handler(Handler) record handler})
until some time after the given completionHandler
is called. In contrast, the once the given completionHandler
is called the batchHandler(Handler)
will only see messages
consistent with the new set of topics.
topics
- topics to subscribe tocompletionHandler
- handler called on operation completedKafkaReadStream<K,V> subscribe(Pattern pattern, Handler<AsyncResult<Void>> completionHandler)
Due to internal buffering of messages, when changing the subscribed topics
the old set of topics may remain in effect
(as observed by the handler(Handler) record handler})
until some time after the given completionHandler
is called. In contrast, the once the given completionHandler
is called the batchHandler(Handler)
will only see messages
consistent with the new set of topics.
pattern
- Pattern to subscribe tocompletionHandler
- handler called on operation completedFuture<Void> subscribe(Pattern pattern)
pattern
- Pattern to subscribe toFuture
completed with the operation resultFuture<Void> unsubscribe()
KafkaReadStream<K,V> unsubscribe(Handler<AsyncResult<Void>> completionHandler)
completionHandler
- handler called on operation completedKafkaReadStream<K,V> subscription(Handler<AsyncResult<Set<String>>> handler)
handler
- handler called on operation completedFuture<Set<String>> subscription()
subscription(Handler)
but returns a Future
of the asynchronous resultFuture<Void> assign(Set<org.apache.kafka.common.TopicPartition> partitions)
partitions
- partitions which want assignedKafkaReadStream<K,V> assign(Set<org.apache.kafka.common.TopicPartition> partitions, Handler<AsyncResult<Void>> completionHandler)
Due to internal buffering of messages, when reassigning
the old set of partitions may remain in effect
(as observed by the handler(Handler) record handler)}
until some time after the given completionHandler
is called. In contrast, the once the given completionHandler
is called the batchHandler(Handler)
will only see messages
consistent with the new set of partitions.
partitions
- partitions which want assignedcompletionHandler
- handler called on operation completedKafkaReadStream<K,V> assignment(Handler<AsyncResult<Set<org.apache.kafka.common.TopicPartition>>> handler)
handler
- handler called on operation completedFuture<Set<org.apache.kafka.common.TopicPartition>> assignment()
assignment(Handler)
but returns a Future
of the asynchronous resultKafkaReadStream<K,V> listTopics(Handler<AsyncResult<Map<String,List<org.apache.kafka.common.PartitionInfo>>>> handler)
handler
- handler called on operation completedFuture<Map<String,List<org.apache.kafka.common.PartitionInfo>>> listTopics()
listTopics(Handler)
but returns a Future
of the asynchronous resultFuture<Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata>> commit()
void commit(Handler<AsyncResult<Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata>>> completionHandler)
completionHandler
- handler called on operation completedFuture<Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata>> commit(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> offsets)
offsets
- offsets list to commitFuture
completed with the operation resultvoid 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)
offsets
- offsets list to commitcompletionHandler
- handler called on operation completedKafkaReadStream<K,V> partitionsFor(String topic, Handler<AsyncResult<List<org.apache.kafka.common.PartitionInfo>>> handler)
topic
- topic partition for which getting partitions infohandler
- handler called on operation completedFuture<List<org.apache.kafka.common.PartitionInfo>> partitionsFor(String topic)
partitionsFor(String, Handler)
but returns a Future
of the asynchronous resultvoid close(Handler<AsyncResult<Void>> completionHandler)
completionHandler
- handler called on operation completedvoid position(org.apache.kafka.common.TopicPartition partition, Handler<AsyncResult<Long>> handler)
partition
- The partition to get the position forhandler
- handler called on operation completedFuture<Long> position(org.apache.kafka.common.TopicPartition partition)
position(TopicPartition, Handler)
but returns a Future
of the asynchronous resultvoid offsetsForTimes(Map<org.apache.kafka.common.TopicPartition,Long> topicPartitionTimestamps, Handler<AsyncResult<Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndTimestamp>>> handler)
topicPartitionTimestamps
- A map with pairs of (TopicPartition, Timestamp).handler
- handler called on operation completedFuture<Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndTimestamp>> offsetsForTimes(Map<org.apache.kafka.common.TopicPartition,Long> topicPartitionTimestamps)
offsetsForTimes(Map, Handler)
but returns a Future
of the asynchronous resultvoid offsetsForTimes(org.apache.kafka.common.TopicPartition topicPartition, long timestamp, Handler<AsyncResult<org.apache.kafka.clients.consumer.OffsetAndTimestamp>> handler)
topicPartition
- Partition to query.timestamp
- Timestamp used to determine the offset.handler
- handler called on operation completedFuture<org.apache.kafka.clients.consumer.OffsetAndTimestamp> offsetsForTimes(org.apache.kafka.common.TopicPartition topicPartition, long timestamp)
offsetsForTimes(TopicPartition, long, Handler)
but returns a Future
of the asynchronous resultvoid beginningOffsets(Set<org.apache.kafka.common.TopicPartition> topicPartitions, Handler<AsyncResult<Map<org.apache.kafka.common.TopicPartition,Long>>> handler)
topicPartitions
- the partitions to get the earliest offsets.handler
- handler called on operation completed. Returns the earliest available offsets for the given partitionsFuture<Map<org.apache.kafka.common.TopicPartition,Long>> beginningOffsets(Set<org.apache.kafka.common.TopicPartition> topicPartitions)
beginningOffsets(Set, Handler)
but returns a Future
of the asynchronous resultvoid beginningOffsets(org.apache.kafka.common.TopicPartition topicPartition, Handler<AsyncResult<Long>> handler)
topicPartition
- the partition to get the earliest offset.handler
- handler called on operation completed. Returns the earliest available offset for the given partitionFuture<Long> beginningOffsets(org.apache.kafka.common.TopicPartition topicPartition)
beginningOffsets(TopicPartition, Handler)
but returns a Future
of the asynchronous resultvoid endOffsets(Set<org.apache.kafka.common.TopicPartition> topicPartitions, Handler<AsyncResult<Map<org.apache.kafka.common.TopicPartition,Long>>> handler)
topicPartitions
- the partitions to get the end offsets.handler
- handler called on operation completed. The end offsets for the given partitions.Future<Map<org.apache.kafka.common.TopicPartition,Long>> endOffsets(Set<org.apache.kafka.common.TopicPartition> topicPartitions)
endOffsets(Set, Handler)
but returns a Future
of the asynchronous resultvoid endOffsets(org.apache.kafka.common.TopicPartition topicPartition, Handler<AsyncResult<Long>> handler)
topicPartition
- the partition to get the end offset.handler
- handler called on operation completed. The end offset for the given partition.Future<Long> endOffsets(org.apache.kafka.common.TopicPartition topicPartition)
endOffsets(TopicPartition, Handler)
but returns a Future
of the asynchronous resultKafkaReadStream<K,V> batchHandler(Handler<org.apache.kafka.clients.consumer.ConsumerRecords<K,V>> handler)
record handler
.handler
- handler called each time Kafka returns a batch of records.KafkaReadStream<K,V> pollTimeout(java.time.Duration timeout)
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.void poll(java.time.Duration timeout, Handler<AsyncResult<org.apache.kafka.clients.consumer.ConsumerRecords<K,V>>> handler)
timeout
- The maximum time to block (must not be greater than Long.MAX_VALUE
milliseconds)handler
- handler called after the poll with batch of records (can be empty).Future<org.apache.kafka.clients.consumer.ConsumerRecords<K,V>> poll(java.time.Duration timeout)
poll(Duration, Handler)
but returns a Future
of the asynchronous resultCopyright © 2021 Eclipse. All rights reserved.