|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Consumer
KafkaConsumer
,
MockConsumer
Method Summary | |
---|---|
void |
close()
Close this consumer |
OffsetMetadata |
commit(boolean sync)
Commits offsets returned on the last poll() for the subscribed list of topics and partitions. |
OffsetMetadata |
commit(java.util.Map<TopicPartition,java.lang.Long> offsets,
boolean sync)
Commits the specified offsets for the specified list of topics and partitions to Kafka. |
java.util.Map<TopicPartition,java.lang.Long> |
committed(java.util.Collection<TopicPartition> partitions)
Fetches the last committed offsets for the input list of partitions |
java.util.Map<java.lang.String,? extends Metric> |
metrics()
Return a map of metrics maintained by the consumer |
java.util.Map<TopicPartition,java.lang.Long> |
offsetsBeforeTime(long timestamp,
java.util.Collection<TopicPartition> partitions)
Fetches offsets before a certain timestamp |
java.util.Map<java.lang.String,ConsumerRecords> |
poll(long timeout)
Fetches data for the subscribed list of topics and partitions |
java.util.Map<TopicPartition,java.lang.Long> |
position(java.util.Collection<TopicPartition> partitions)
Returns the fetch position of the next message for the specified topic partition to be used on the next poll() |
void |
seek(java.util.Map<TopicPartition,java.lang.Long> offsets)
Overrides the fetch positions that the consumer will use on the next fetch request. |
void |
subscribe(java.lang.String... topics)
Incrementally subscribe to the given list of topics. |
void |
subscribe(TopicPartition... partitions)
Incrementally subscribes to a specific topic and partition. |
void |
unsubscribe(java.lang.String... topics)
Unsubscribe from the specific topics. |
void |
unsubscribe(TopicPartition... partitions)
Unsubscribe from the specific topic partitions. |
Method Detail |
---|
void subscribe(java.lang.String... topics)
subscribe(partitions)
topics
- A variable list of topics that the consumer subscribes tovoid subscribe(TopicPartition... partitions)
subscribe(topics)
partitions
- Partitions to subscribe tovoid unsubscribe(java.lang.String... topics)
poll()
onwards. This should be used in conjunction with subscribe(topics)
. It is an error to
unsubscribe from a topic that was never subscribed to using subscribe(topics)
topics
- Topics to unsubscribe fromvoid unsubscribe(TopicPartition... partitions)
poll()
onwards. This should be used in conjunction with
subscribe(topic, partitions)
. It is an error to
unsubscribe from a partition that was never subscribed to using subscribe(partitions)
partitions
- Partitions to unsubscribe fromjava.util.Map<java.lang.String,ConsumerRecords> poll(long timeout)
timeout
- The time, in milliseconds, spent waiting in poll if data is not available. If 0, waits indefinitely. Must not be negative
ConsumerConfig.FETCH_MIN_BYTES_CONFIG
and ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG
.
If no data is available for timeout ms, returns an empty listOffsetMetadata commit(boolean sync)
poll()
for the subscribed list of topics and partitions.
sync
- If true, the commit should block until the consumer receives an acknowledgment
OffsetMetadata
object that contains the partition, offset and a corresponding error code. Returns null
if the sync flag is set to falseOffsetMetadata commit(java.util.Map<TopicPartition,java.lang.Long> offsets, boolean sync)
offsets
- The map of offsets to commit for the given topic partitionssync
- If true, commit will block until the consumer receives an acknowledgment
OffsetMetadata
object that contains the partition, offset and a corresponding error code. Returns null
if the sync flag is set to false.void seek(java.util.Map<TopicPartition,java.lang.Long> offsets)
subscribe(topics)
, an exception will be thrown if the specified topic partition is not owned by
the consumer.
offsets
- The map of fetch positions per topic and partitionjava.util.Map<TopicPartition,java.lang.Long> position(java.util.Collection<TopicPartition> partitions)
poll()
partitions
- Partitions for which the fetch position will be returned
poll()
java.util.Map<TopicPartition,java.lang.Long> committed(java.util.Collection<TopicPartition> partitions)
partitions
- The list of partitions to return the last committed offset for
java.util.Map<TopicPartition,java.lang.Long> offsetsBeforeTime(long timestamp, java.util.Collection<TopicPartition> partitions)
timestamp
- The unix timestamp. Value -1 indicates earliest available timestamp. Value -2 indicates latest available timestamp.partitions
- The list of partitions for which the offsets are returned
java.util.Map<java.lang.String,? extends Metric> metrics()
void close()
close
in interface java.io.Closeable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |