public interface Consumer<V>
| Modifier and Type | Method and Description |
|---|---|
Set<TopicPartition> |
assignment()
Get the set of partitions currently assigned to this consumer.
|
Map<TopicPartition,Long> |
beginningOffsets(String topic) |
void |
close()
close consumer
|
void |
commitAsync(Map<TopicPartition,OffsetAndMetadata> offsets,
OffsetCommitCallback<V> callback) |
void |
commitAsync(OffsetCommitCallback<V> callback) |
void |
commitSync()
commit offset with sync
|
void |
commitSync(Map<TopicPartition,OffsetAndMetadata> offsets) |
Map<TopicPartition,OffsetAndMetadata> |
committed(Set<TopicPartition> partitions) |
OffsetAndMetadata |
committed(TopicPartition partition)
Get the last committed offset for the given partition.
|
void |
create(Properties properties)
create consumer
|
Map<TopicPartition,Long> |
endOffsets(String topic) |
ConsumerRecords<V> |
poll(Duration timeout,
Deserializer<V> deserializer)
get result records
|
Map<TopicPartition,Long> |
position(String topic) |
long |
position(TopicPartition partition)
Get the offset of the next record that will be fetched.
|
void |
seek(TopicPartition partition,
long offset)
If this API is invoked for the same partition more than once, the latest offset will be used on the next poll().
|
void |
seekToBeginning(Collection<TopicPartition> partitions) |
void |
seekToEnd(Collection<TopicPartition> partitions) |
void |
subscribe(Collection<String> topics)
subscribe topics
|
Set<String> |
subscription()
get subscribe topics
|
void |
unsubscribe()
unsubscribe topics
|
void create(Properties properties) throws SQLException
properties - ip / port / user / password and so on.SQLException - jni exceptionvoid subscribe(Collection<String> topics) throws SQLException
topics - collection of topicsSQLExceptionvoid unsubscribe()
throws SQLException
SQLExceptionSet<String> subscription() throws SQLException
SQLExceptionConsumerRecords<V> poll(Duration timeout, Deserializer<V> deserializer) throws SQLException
timeout - wait time for poll datadeserializer - convert resultSet to javaBeanSQLException - java reflect exception or resultSet convert exceptionvoid commitSync()
throws SQLException
SQLExceptionvoid close()
throws SQLException
SQLExceptionvoid commitAsync(OffsetCommitCallback<V> callback) throws SQLException
SQLExceptionvoid seek(TopicPartition partition, long offset) throws SQLException
SQLExceptionlong position(TopicPartition partition) throws SQLException
SQLExceptionMap<TopicPartition,Long> position(String topic) throws SQLException
SQLExceptionMap<TopicPartition,Long> beginningOffsets(String topic) throws SQLException
SQLExceptionMap<TopicPartition,Long> endOffsets(String topic) throws SQLException
SQLExceptionvoid seekToBeginning(Collection<TopicPartition> partitions) throws SQLException
SQLExceptionvoid seekToEnd(Collection<TopicPartition> partitions) throws SQLException
SQLExceptionSet<TopicPartition> assignment() throws SQLException
SQLExceptionOffsetAndMetadata committed(TopicPartition partition) throws SQLException
SQLExceptionMap<TopicPartition,OffsetAndMetadata> committed(Set<TopicPartition> partitions) throws SQLException
SQLExceptionvoid commitSync(Map<TopicPartition,OffsetAndMetadata> offsets) throws SQLException
SQLExceptionvoid commitAsync(Map<TopicPartition,OffsetAndMetadata> offsets, OffsetCommitCallback<V> callback)
Copyright © 2025. All rights reserved.