简体   繁体   English

如何在 Spring Cloud Stream 中同时具有消费者和生产者事务的应用程序中设置事务 ID 前缀

[英]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.

相关问题 Spring Cloud Stream 不会向 RabbitMQ 发送消息,而是在同一个 pod 中消费。 生产者和消费者在同一个应用程序中 - Spring Cloud Stream is not sending messages to RabbitMQ, instead consumes in the same pod. Producer and Consumer are in the same app 使用 rabbitmq 时如何分别配置消费者和生产者 spring 启动应用程序? - How to configure separately both consumer and producer spring boot app when using rabbitmq? Spring Cloud Stream Producer在使用Spring Kafka Consumer时添加了“垃圾”字符 - Spring Cloud Stream Producer adds “junk” characters when using Spring Kafka Consumer Spring 云 stream 功能性生产者/消费者 bean 在 @SpringBootApplication 之外声明时不起作用 - Spring cloud stream functional producer/consumer bean is not working when declared out side of @SpringBootApplication Spring Cloud Stream KStream使用者并发没有影响? - Spring Cloud Stream KStream Consumer Concurrency has no effect? Spring 云 stream 在同一应用程序中声明生产者和消费者时不向 Kafka 发送消息 - Spring cloud stream not send message to Kafka when declare producer and consumer in the same application Spring Cloud Stream (Hoxton) Kafka Producer/Consumer 无法与 EmbeddedKafka 进行集成测试 - Spring Cloud Stream (Hoxton) Kafka Producer / Consumer not working in integration tests with EmbeddedKafka 仅拦截来自使用者的Spring Cloud Stream消息 - Intercepting Spring Cloud Stream Messages from Consumer only Spring 云 Stream 消费者启动 - Spring Cloud Stream consumer startup 如何使用 Spring Cloud Kafka Stream 3.1 创建生产者 - How can create a producer using Spring Cloud Kafka Stream 3.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM