Modifier and Type | Interface and Description |
---|---|
static interface |
PullConsumer.TopicPartitionChangeListener |
Modifier and Type | Method and Description |
---|---|
void |
assign(Collection<TopicPartition> topicPartitions)
Manually assign a list of partitions to this consumer.
|
void |
commitSync()
Sync commit current consumed offset to server.
|
Long |
committed(TopicPartition topicPartition)
Get the last committed offset for the given message queue (whether the commit happened by this process or
another).
|
Long |
offsetForTimestamp(TopicPartition topicPartition,
Long timestamp)
Look up the offsets for the given message queue by timestamp.
|
void |
pause(Collection<TopicPartition> topicPartitions)
Suspend fetching from the requested message queues.
|
List<Message> |
poll(long timeout)
Fetch data for the topics or partitions specified using assign API.
|
void |
registerTopicPartitionChangedListener(String topic,
PullConsumer.TopicPartitionChangeListener callback)
Register a callback for sensing topic metadata changes.
|
void |
resume(Collection<TopicPartition> topicPartitions)
Resume specified message queues which have been paused with
pause(Collection) . |
void |
seek(TopicPartition topicPartition,
long offset)
Overrides the fetch offsets that the consumer will use on the next
poll(long) }. |
void |
seekToBeginning(TopicPartition topicPartition)
Overrides the fetch offsets with the beginning offset in server that the consumer will use on the next
poll(long) }. |
void |
seekToEnd(TopicPartition topicPartition)
Overrides the fetch offsets with the end offset in server that the consumer will use on the next
poll(long) }. |
Set<TopicPartition> |
topicPartitions(String topic)
Get metadata about the partitions for a given topic.
|
Set<TopicPartition> topicPartitions(String topic)
topic
- void assign(Collection<TopicPartition> topicPartitions)
topicPartitions
- void registerTopicPartitionChangedListener(String topic, PullConsumer.TopicPartitionChangeListener callback)
topic
- callback
- List<Message> poll(long timeout)
timeout
- in millisecondvoid seek(TopicPartition topicPartition, long offset)
poll(long)
}. If this API is invoked
for the same message queue more than once, the latest offset will be used on the next poll(). Note that you may
lose data if this API is arbitrarily used in the middle of consumption.topicPartition
- offset
- void seekToBeginning(TopicPartition topicPartition)
poll(long)
}.topicPartition
- void seekToEnd(TopicPartition topicPartition)
poll(long)
}.topicPartition
- void pause(Collection<TopicPartition> topicPartitions)
poll(long)
will not return any
records from these message queues until they have been resumed using resume(Collection)
.
Note that this method does not affect message queue subscription. In particular, it does not cause a group
rebalance.topicPartitions
- void resume(Collection<TopicPartition> topicPartitions)
pause(Collection)
. New calls to poll(long)
will return records from these partitions if there are any to be fetched. If the message queues were
not previously paused, this method is a no-op.topicPartitions
- Long offsetForTimestamp(TopicPartition topicPartition, Long timestamp)
topicPartition
- timestamp
- Long committed(TopicPartition topicPartition)
topicPartition
- void commitSync()
Copyright © 2012–2020. All rights reserved.