我无法评论类似的主题:TransactionId prefix for producer-only and read-process-write - ProducerFencedException所以我会问一个新问题。
用例:
1)我启动第一个应用程序实例(我们称其为“ instance1”-一切正常-单个使用者同时订阅了两个分区。日志:
o.s.k.l.KafkaMessageListenerContainer : sample-consumer-group: partitions assigned: [sampleTopic-1, sampleTopic-0]
2)我启动第二个应用程序实例(实例2)-一切正常-从该实例登录:
o.s.k.l.KafkaMessageListenerContainer : sample-consumer-group: partitions assigned: [sampleTopic-1]
来自“ instance1”的日志:
o.s.k.l.KafkaMessageListenerContainer : sample-consumer-group: partitions revoked: [sampleTopic-1, sampleTopic-0] o.s.k.l.KafkaMessageListenerContainer : sample-consumer-group: partitions assigned: [sampleTopic-0]
仍然看起来还不错...但是,当我然后尝试将消息发送到任何其他主题(不是从任何kafkaListener而是从某些@Transactional方法发送)时,会发生以下错误:
ERROR 4395 --- [roducer-tx-prefix-0] o.a.k.clients.producer.internals.Sender : [Producer clientId=producer-tx-prefix-0, transactionalId=tx-prefix-0] Aborting producer batches due to fatal error org.apache.kafka.common.errors.ProducerFencedException: Producer attempted an operation with an old epoch. Either there is a newer producer with the same transactionalId, or the producer's transaction has been expired by the broker. ERROR 4395 --- [roducer-tx-prefix-0] o.s.k.support.LoggingProducerListener : Exception thrown when sending a message with key='sync-register' and payload='2020-04-21T13:52:12.148412Z' to topic anotherTopic
因此,对于仅生产者事务,每个实例都应具有单独的transaction-id-prefix吗?如果是,当前状态是什么?如何在不使用单独的kafkaTemplate进行消费者启动和生产者启动的交易的情况下实现此目标?
我无法在类似主题上发表评论:仅生产者和读取过程写入的TransactionId前缀-ProducerFencedException,所以我将提出一个新问题。用例:一个带有2个分区的主题Spring ...