transaction-id-prefix需要在Spring Kafka 3中的同一应用程序实例中保持相同吗?

huangapple go评论102阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年5月29日 10:25:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76354349.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定