qungmu commented on issue #556:
URL:
https://github.com/apache/rocketmq-spring/issues/556#issuecomment-3102016363
1. @RocketMQMessageListener(topic = "test1",consumerGroup = "consumerGroup")
2. @RocketMQMessageListener(topic = "test2",consumerGroup = "consumerGroup")
// 这样违反的订阅一致性原则,相当于创建了两个消费者,且属于同一个group中,两个消费者分别订阅了topicA和topicB
你期望实现,代码应该是这样的:
@RocketMQMessageListener(topic = "test1||test2",consumerGroup =
"consumerGroup")
// 但是这样的代码,rocketmq-spring-boot是不支持的,一个消费者只允许定义一个topic
所以想要实现一个group中一个消费者订阅多个topic,应该自己创建DefaultMQPushConsumer实现:
代码如:
DefaultMQPushConsumer consumer = new
DefaultMQPushConsumer("my-consumer-group");
// 订阅 topicA 下所有消息
consumer.subscribe("topicA", "*");
// 同时订阅 topicB 的特定 tag 消息
consumer.subscribe("topicB", "TagA || TagB");
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]