gpt4 book ai didi

Spring Cloud 流式传输并消费多个 kafka 主题

转载 作者:行者123 更新时间:2023-12-02 05:39:37 26 4
gpt4 key购买 nike

在尝试在一个 @StreamListener 中使用多个主题时,我遇到了 spring-boot-stream 的问题。

根据 spring-cloud-stream 文档:根据文档:

destination

The target destination of a channel on the bound middleware (e.g., the RabbitMQ exchange or Kafka topic). If the channel is bound as a consumer, it could be bound to multiple destinations and the destination names can be specified as comma separated String values. If not set, the channel name is used instead. The default value of this > property cannot be overridden.

但是,在我使用下一个配置之后:

spring:
cloud:
stream:
bindings:
testchannel:
group: test
destination: platform.metrics, platform.sleuth

现在我遇到了下一个错误:

Caused by: java.lang.IllegalArgumentException: Topic name can only have ASCII alphanumerics, '.', '_' and '-'
at org.springframework.cloud.stream.binder.kafka.utils.KafkaTopicUtils.validateTopicName(KafkaTopicUtils.java:39) ~[spring-cloud-stream-binder-kafka-core-1.2.1.RELEASE.jar:1.2.1.RELEASE]
at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner.provisionProducerDestination(KafkaTopicProvisioner.java:107) ~[spring-cloud-stream-binder-kafka-core-1.2.1.RELEASE.jar:1.2.1.RELEASE]
at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner.provisionProducerDestination(KafkaTopicProvisioner.java:60) ~[spring-cloud-stream-binder-kafka-core-1.2.1.RELEASE.jar:1.2.1.RELEASE]
at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindProducer(AbstractMessageChannelBinder.java:110) ~[spring-cloud-stream-1.2.2.RELEASE.jar:1.2.2.RELEASE]
... 20 common frames omitted

如何将多个主题绑定(bind)到一个@StreamListner或从主题列表生成动态streamListener?

最佳答案

您只需替换逗号和下一个目标值之间的空格,它就会看起来像:

spring:
cloud:
stream:
bindings:
testchannel:
group: test
destination: platform.metrics,platform.sleuth

关于Spring Cloud 流式传输并消费多个 kafka 主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44615443/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com