apache / rocketmq-spring

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

A project cannot use the same consumer group #641

Closed SuperEdison closed 4 months ago

SuperEdison commented 6 months ago

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):
panzhi33 commented 6 months ago

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

RongtongJin commented 6 months ago

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

SuperEdison commented 6 months ago

rocketmq-spring version 2.3.0 rocketmq version 5.1.4

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