spring-cloud-stream - 每个节点唯一的 Kafka 生产者前缀
spring-cloud-stream - Kafka producer prefix unique per node
我想使用输出通道在仅限生产者(不在读写过程中)事务中向 Kafka 主题发送内容。
我阅读了关于 Whosebug 的文档和另一个主题 ()。
问题是我需要为每个节点设置唯一的 transactionIdPrefix。
有什么建议吗?
这是一种方法...
@Component
class TxIdCustomizer implements EnvironmentAware {
@Override
public void setEnvironment(Environment environment) {
Properties properties = new Properties();
properties.setProperty("spring.cloud.stream.kafka.binder.transaction.transactionIdPrefix",
UUID.randomUUID().toString());
((StandardEnvironment) environment).getPropertySources()
.addLast(new PropertiesPropertySource("txId", properties));
}
}
我想使用输出通道在仅限生产者(不在读写过程中)事务中向 Kafka 主题发送内容。
我阅读了关于 Whosebug 的文档和另一个主题 (
问题是我需要为每个节点设置唯一的 transactionIdPrefix。 有什么建议吗?
这是一种方法...
@Component
class TxIdCustomizer implements EnvironmentAware {
@Override
public void setEnvironment(Environment environment) {
Properties properties = new Properties();
properties.setProperty("spring.cloud.stream.kafka.binder.transaction.transactionIdPrefix",
UUID.randomUUID().toString());
((StandardEnvironment) environment).getPropertySources()
.addLast(new PropertiesPropertySource("txId", properties));
}
}