apache/rocketmq-spring

A project cannot use the same consumer group

SuperEdison opened this issue · 3 comments

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

Any question or RocketMQ proposal please use our mailing lists.

BUG REPORT

  1. Please describe the issue you observed:

image
官方文档上面说的是两个订阅相互独立,但是现在接收不到消息

@Service
@RocketMQMessageListener(consumerGroup = "boot_group_1",topic = "boot-mq-topic1")
public class ConsumerListener implements RocketMQListener<String> {

    private static final Logger log = LoggerFactory.getLogger(ConsumerListener.class);

    @Override
    public void onMessage(String message) {
        log.info("boot-mq-topic1 \n=====\n message:{} \n=====\n",message);
    }
}
@Service
@RocketMQMessageListener(consumerGroup = "boot_group_1",topic = "boot-mq-topic2")
public class ConsumerListener1 implements RocketMQListener<String> {

    private static final Logger log = LoggerFactory.getLogger(ConsumerListener1.class);

    @Override
    public void onMessage(String message) {
        log.info("boot-mq-topic2 \n=====\n message:{} \n=====\n",message);
    }
}
    @GetMapping("/send/msg1")
    public String sendMsg1 (){
        try {
            JsonMapper jsonMapper = new JsonMapper();
            String msgBody = jsonMapper.writeValueAsString(new MqMsg(1,"boot_mq_msg"));
            String msgBody1 = jsonMapper.writeValueAsString(new MqMsg(2,"boot_mq_msg"));
            SendResult sendResult1 = rocketMqTemplate.syncSend("boot-mq-topic1", msgBody);
            SendResult sendResult2 = rocketMqTemplate.syncSend("boot-mq-topic2", msgBody1);
            System.out.println(sendResult1.getSendStatus());
            System.out.println(sendResult2.getSendStatus());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "OK" ;
    }
  1. Please tell us about your environment:
    走的是官方文档的部署过程版本5.1.4
  2. Other information (e.g. detailed explanation, logs, related issues, suggestions how to fix, etc):

springboot不支持这种方式,这样使用应该订阅关系不一致了,需要使用不同的group

@SuperEdison 用的是什么版本?可以设置不同的instanceName来解决

rocketmq-spring version 2.3.0
rocketmq version 5.1.4

@SuperEdison 用的是什么版本?可以设置不同的instanceName来解决