apache / rocketmq-spring

Apache RocketMQ Spring Integration
https://rocketmq.apache.org/
Apache License 2.0
2.11k stars 896 forks source link

v5 版本中如何让消息在同一个服务的多个实例中广播呢? #588

Open liuweiGL opened 1 year ago

liuweiGL commented 1 year ago

The issue tracker is ONLY used for bug report and feature request.

Any question or RocketMQ proposal please use our mailing lists.

FEATURE REQUEST

  1. Please describe the feature you are requesting. 在 spring cloud 项目中启动多个实例,希望消息能在多个实例中广播消费

  2. Provide any additional detail on your proposed use case for this feature. 项目中用到了 websocket 推送,然后借助消息队列实现消息转发

A Producer -> sendMessage -> RocketMQ ->  A PushConsumer 接受 -> websocket 发送到页面
                                      ->  B PushConsumer 接受 -> websocket 发送到页面

A、B 为同一个服务的多个实例

我尝试按照文档使用多个 consumerGroup 但是会报错 image


使用的包为 rocketmq-v5-client-spring-boot-starter-2.2.4-SNAPSHOT

liuweiGL commented 1 year ago

有没有大佬帮忙解答一下呢?

lizhanhui commented 1 year ago

@liuweiGL

1) 目前适配的sprintboot注解不太满足你的需求;

2) 每个web socket连接都对应一个的Consumer, 有些浪费资源。 构建一个WebSocketManager,组合一个Consumer 实例(独立的Group), WebSocketManager管理N个web socket, 负责将consumer获取的消息fan-out。

3) 每个你的业务节点Node,根据你的业务特点,包含1个或者多个WebSocketManager。