K - the type of key for records consumed from KafkaV - the type of value for records consumed from Kafkapublic final class LcKafkaConsumer<K,V> extends Object implements Closeable
LcKafkaConsumer is a wrapper over Consumer. It will use Consumer to consume
records from Kafka broker.
With LcKafkaConsumer, you can subscribe to several topics and handle all the records from these topics
in a dedicated thread pool without warring polling timeout or session timeout due to the polling thread spend
too much time on process records and failed to poll broker at least once within max.poll.interval.ms.
All the public methods in LcKafkaConsumer is thread safe.
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
Map<org.apache.kafka.common.MetricName,? extends org.apache.kafka.common.Metric> |
metrics()
Get the metrics kept by the consumer
|
void |
subscribe(Collection<String> topics)
Subscribe some Kafka topics to consume records from them.
|
public void subscribe(Collection<String> topics)
topics - the topics to consume.IllegalStateException - if this LcKafkaConsumer has closed or subscribed to some topicsIllegalArgumentException - if the input topics is emptypublic Map<org.apache.kafka.common.MetricName,? extends org.apache.kafka.common.Metric> metrics()
public void close()
close in interface Closeableclose in interface AutoCloseableCopyright © 2020 LeanCloud. All rights reserved.