admin管理员组文章数量:1122846
I use Spring Cloud Stream v4.
Here is my application.yml code:
spring:
cloud:
stream:
kafka:
binder:
configuration:
key.serializer: org.apache.kafkamon.serialization.StringSerializer
key.deserializer: org.apache.kafkamon.serialization.StringDeserializer
bindings:
userUpdatedCluster1-in-0:
destination: test-1
binder: kafkaCluster1
group: xx
userUpdatedCluster2-in-0:
destination: test2
binder: kafkaCluster2
group: yy
binders:
kafkaCluster1:
type: kafka
environment:
spring:
kafka:
bootstrap-servers: public--dev.abcd:23100
properties:
security.protocol: PLAINTEXT
kafkaCluster2:
type: kafka
environment:
spring:
kafka:
bootstrap-servers: public--dev.efgh:23100
properties:
security.protocol: PLAINTEXT
And here is my consumer:
@Component("userUpdatedCluster1")
public class UserUpdatedEventConsumer implements Consumer<Message<UserUpdatedEvent>> {
private final UserService userService;
public UserUpdatedEventConsumer(UserService userService) {
this.userService = userService;
}
@Override
public void accept(Message<UserUpdatedEvent> message) {
UserUpdatedEvent event = message.getPayload();
userService.printUpdatedUserInfo(event.id(), event.name(), event.age());
}
}
With this setup, my consumer can successfully consume messages from userUpdatedCluster1-in-0
binding and it successfully consumes from userUpdatedCluster2-in-0
binding if I change the consumer bean name accordingly.
Question: As I have same message structure in both cluster topics, I want to find out whether it is possible to have such configuration so that a single consumer bean consumes messages from both bindings at the same time without declaring separate beans per binding.
本文标签:
版权声明:本文标题:Spring Cloud Stream: Can a single consumer bean consume messages from different message broker clusters? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736309322a1933978.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论