问题
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