public interface Consumer<V>
| 限定符和类型 | 方法和说明 |
|---|---|
Map<TopicPartition,Long> |
beginningOffsets(String topic) |
void |
close()
close consumer
|
void |
commitAsync(OffsetCommitCallback<V> callback) |
void |
commitSync()
commit offset with sync
|
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) |
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 |
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 topicsSQLException - jni exceptionvoid unsubscribe()
throws SQLException
SQLException - jni exceptionSet<String> subscription() throws SQLException
SQLException - jni exceptionConsumerRecords<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
SQLException - jni exceptionvoid close()
throws SQLException
SQLException - jni exceptionvoid commitAsync(OffsetCommitCallback<V> callback)
void 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
SQLExceptionCopyright © 2023. All rights reserved.