public class KafkaBatchListener extends Object
| 构造器和说明 |
|---|
KafkaBatchListener(Executor executor,
KafkaBatchConsumer consumer) |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
asyncConsume(List<List<org.apache.kafka.clients.consumer.ConsumerRecord<String,String>>> pageList,
KafkaBatchContext context)
多线程消费
|
boolean |
consume(List<org.apache.kafka.clients.consumer.ConsumerRecord<String,String>> records,
KafkaBatchContext context)
执行消费
|
KafkaBatchConsumer |
getConsumer() |
Executor |
getExecutor() |
int |
getThreadNum() |
boolean |
listen(List<org.apache.kafka.clients.consumer.ConsumerRecord<String,String>> records,
KafkaBatchContext context)
计算分页,多线程消费
|
KafkaBatchListener |
setThreadNum(int threadNum)
设置线程数
实际线程数 = CEIL(总行数 / CEIL(总行数 / 线程数))
|
public KafkaBatchListener(Executor executor, KafkaBatchConsumer consumer)
public boolean listen(List<org.apache.kafka.clients.consumer.ConsumerRecord<String,String>> records, @Nullable KafkaBatchContext context)
records - 消息列表context - 消费上下文public boolean asyncConsume(@NonNull
List<List<org.apache.kafka.clients.consumer.ConsumerRecord<String,String>>> pageList,
@Nullable
KafkaBatchContext context)
pageList - 分页列表context - 消费上下文public boolean consume(List<org.apache.kafka.clients.consumer.ConsumerRecord<String,String>> records, @Nullable KafkaBatchContext context)
records - 消息列表context - 消费上下文public Executor getExecutor()
public KafkaBatchConsumer getConsumer()
public int getThreadNum()
public KafkaBatchListener setThreadNum(int threadNum)
threadNum - 线程数,线程数 小于 (线程池最大线程数 - 1)KafkaBatchListener instanceCopyright © 2023. All rights reserved.