[英]How to set transaction-id-prefix in app which has both consumer and producer-only transactions in Spring Cloud Stream
For transactions that have been started by a listener container, we need to set the same transaction id prefix for all app instances.对于已由侦听器容器启动的事务,我们需要为所有应用程序实例设置相同的事务 ID 前缀。 For producing-only transaction, we need to set a different value for each instance instead.
对于仅生产事务,我们需要为每个实例设置不同的值。
I'm using Spring Cloud Stream Kafka Binder in the app which has both types of transactions, and the property spring.cloud.stream.kafka.binder.transaction.transaction-id-prefix
is used for creating a common transaction manager.我在具有两种事务类型的应用程序中使用 Spring Cloud Stream Kafka Binder,并且属性
spring.cloud.stream.kafka.binder.transaction.transaction-id-prefix
用于创建通用事务管理器。
I wonder how to make it all work properly because it seems that you can't have it both ways at the same time.我想知道如何使这一切正常工作,因为您似乎不能同时拥有这两种方式。
That requirement is no longer necessary if your broker is 2.5 or later and you are using a currently supported version of spring-cloud-stream (3.2.x) and spring-kafka (2.8.x).如果您的代理是 2.5 或更高版本并且您正在使用当前支持的 spring-cloud-stream (3.2.x) 和 spring-kafka (2.8.x) 版本,则不再需要该要求。
You must now use a unique prefix even for consumer-initiated transactions.即使是消费者发起的交易,您现在也必须使用唯一前缀。
If you are using an older broker or an unsupported spring-kafka version that does not use EOSMode V2 (BETA) by default, you can configure two binders.如果您使用的是较旧的 broker 或默认不使用 EOSMode V2 (BETA) 的不受支持的 spring-kafka 版本,则可以配置两个 binder。
https://docs.spring.io/spring-kafka/docs/current/reference/html/#transaction-id-prefix https://docs.spring.io/spring-kafka/docs/current/reference/html/#transaction-id-prefix
This problem (different rules for transactional.id) has been eliminated when EOSMode.BETA is being used (with broker versions >= 2.5);
这个问题(transactional.id 的不同规则)在使用 EOSMode.BETA 时已经消除(代理版本 >= 2.5); see Exactly Once Semantics.
请参阅 Exactly Once 语义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.