英文:
transaction-id-prefix need to be identical for same application instance in spring kafka 3?
问题
在Spring Kafka 3中,如果应用程序运行多个实例,你需要一个唯一的transaction-id-prefix。以下是我的配置:
fun getTxnIdPrefix() {
return "$hostname-mytransaction-id-prefix-${UUID.randomUUID()}"
}
在这种情况下:
hostA-mytransaction-id-prefix-abcd123xxx
应用程序崩溃并重新启动
hostA-mytransaction-id-prefix-mnbmgjh698
在应用程序崩溃/重新启动的情况下,同一实例的transaction-id-prefix是否需要相同?
我从Confluent博客transactions-apache-kafka上看到,建议在应用程序实例崩溃/重新启动之前/之后,transaction-id-prefix需要相同,以便查找任何未完成的事务。
英文:
I understand in spring kafka 3, I need a unique transaction-id-prefix for applications running with multiple instances. here is my configuration:
fun getTxnIdPrefix() {
return "$hostname-mytransaction-id-prefix-${UUID.randomUUID()}"
}
in this case:
hostA-mytransaction-id-prefix-abcd123xxx
app crash and restart
hostA-mytransaction-id-prefix-mnbmgjh698
does transaction-id-prefix need to be identical for same instance in case application crash/restart?
I saw from confluent blog transactions-apache-kafka suggests the transaction-id-prefix need to be identical before/after application instance crash/restart, in order to look for any pending transaction?
答案1
得分: 1
可以不同;但是,如果在实例宕机时有正在进行的事务,那么将会有延迟。在该事务超时之前,消费者将无法接收后续记录。
请参阅 https://kafka.apache.org/documentation/#producerconfigs_transaction.timeout.ms
英文:
It can be different; however, there will be a delay if there was an in-progress transaction when the instance went down. That transaction will have to time out before a consumer will receive later records.
See https://kafka.apache.org/documentation/#producerconfigs_transaction.timeout.ms
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论