我的rocketMQ 2m-noslave不能消费消息

我在我的服务器上构建了一个rocketmq服务器,它是2m-noslave集群,它可以发送消息给rocketmq,但我的消费者无法接收消息,有人告诉我哪里出错了,认为......这是我的消费者CLass代码:

public class Consumer{

    public static final String CONSUMER_GROUP_NAME = "broker-b";
    public static final String CLUSTER_ADDR = "120.27.128.207:9876;120.27.146.42:9876";
    public static final String SUBSCRIBE = "dzg_topic_001";

    private void consumerMessage() throws MQClientException {
        DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(CONSUMER_GROUP_NAME);
        consumer.setNamesrvAddr(CLUSTER_ADDR);
        consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
        consumer.setMessageModel(MessageModel.CLUSTERING);
        //设置批量消费个数
        consumer.subscribe(SUBSCRIBE, "*");

        consumer.registerMessageListener((List<MessageExt> msgList, ConsumeConcurrentlyContext context)->{
            MessageExt msg = msgList.get(0);
            System.out.println( "received new message:  topic===="+msg.getTopic()+"  tag==="+msg.getTags()+"  body=="+new String(msg.getBody()));
            return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
        });
        consumer.start();
        System.out.println("ConsumerStarted.");

    }


    public static void main(String[] args) {
        try {
            new Consumer().consumerMessage();
        } catch (MQClientException e) {
            e.printStackTrace();
        }
    }


}

而我的rocketmq服务器是enter image description here

回答(1)

3 years ago

当我设置属性autoCreateTopicEnable和autoCreateSubscriptionGroup'svalue为true时,消费者是对的,为什么设置false消费者是不行的呢?