apache / rocketmq-spring

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

Does version 2.1.0 support spring-boot 2.2.6 or two consumers in one consumerGroup? #259

Closed githubzsy closed 4 years ago

githubzsy commented 4 years 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:

my spring-boot version is 2.2.6 dependency : rocketmq-spring-boot-starter two consumers in one consumerGroup version 2.0.3 work correctly version 2.1.0 exception occurred: Caused by: org.apache.rocketmq.client.exception.MQClientException: The consumer group[my-consumer_test-topic_1] has been created before, specify another name please.

java code:

package com.example.mq.rocketmq;

public class RocketConstants {

    public static final String TEST_TOPIC = "test-topic";

    public static final String CONSUMER_GROUP1 = "my-consumer_test-topic_1";
}
package com.example.mq.rocketmq;

import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

/**
 * consumerGroup=消费者组的名称
 */
@Service
@RocketMQMessageListener(consumerGroup = RocketConstants.CONSUMER_GROUP1, topic = RocketConstants.TEST_TOPIC)
public class RocketConsumer implements RocketMQListener<String> {

    @Override
    public void onMessage(String message) {
        System.err.println("RocketConsumer接收到消息:" + message);
    }
}
package com.example.mq.rocketmq;

import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

/**
 * consumerGroup=消费者组的名称
 */
@Service
@RocketMQMessageListener(consumerGroup = RocketConstants.CONSUMER_GROUP1, topic = RocketConstants.TEST_TOPIC)
public class RocketConsumer2 implements RocketMQListener<String> {

    @Override
    public void onMessage(String message) {
        System.err.println("RocketConsumer2接收到消息:" + message);
    }
}
  1. Please tell us about your environment:

  2. Other information (e.g. detailed explanation, logs, related issues, suggestions how to fix, etc):

FEATURE REQUEST

  1. Please describe the feature you are requesting.

  2. Provide any additional detail on your proposed use case for this feature.

  3. Indicate the importance of this issue to you (blocker, must-have, should-have, nice-to-have). Are you currently using any workarounds to address this issue?

RongtongJin commented 4 years ago

Hi @githubzsy , plz refer to Article 3 of the wiki FAQ. if you must do it, you can set different instance name for consumer in prepareStart method.

githubzsy commented 4 years ago

@RongtongJin 谢谢,设置instanceName后不报错了。