springboot集成rocketmq消费者

消息消费者

1)添加依赖

同消息生产者

2)配置文件

同消息生产者

3)启动类

@SpringBootApplication
public class MQConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(MQSpringBootApplication.class);
    }
}

4)消息监听器

@Slf4j
@Component
@RocketMQMessageListener(topic = "springboot-mq",consumerGroup = "springboot-mq-consumer-1")
public class Consumer implements RocketMQListener {

    @Override
    public void onMessage(String message) {
        log.info("Receive message:"+message);
    }
}

 

你可能感兴趣的:(springboot集成rocketmq消费者)