How to commit offsets thread safe using camel-kafka?

情到浓时终转凉″ 提交于 2021-02-08 10:51:12

问题


As asked in question How to manually control the offset commit with camel-kafka? I want to commit offsets manually using camel-kafka. My route:

.from(kafka:topic1)
 .aggregate(new GroupByExchangeStrategy())
.to(kafka:topic2)
 .process(new ManualCommitProcessor())

, where ManualCommitProcessor will do the commitment after sending the message to another topic.

Problem is that aggregator and kafka producer are working in separated threads to the kafka consumer which is responsible for offset commitment. Hence, I am ending in

java.util.ConcurrentModificationException: KafkaConsumer is not safe for multi-threaded access

Is there a possibility to call the consumer thread again after aggregation and dispatching to commit offsets?


回答1:


No this is not possible, the consumer thread runs independently of the output of the aggregator.



来源:https://stackoverflow.com/questions/56716812/how-to-commit-offsets-thread-safe-using-camel-kafka

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!