背景:现在要使用RocketMQ,要在项目启动的时候先启动消费者Consumer
第一种方式:使用定时器,设置FixedRate无限大,但是总感觉这种方式吧有点蛋疼,估计还会有坑
第二种方式:在消费者类(Consumer)实现ApplicationRunner或者CommandLineRunner接口 完美实现
@Component
public class Consumer implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
this.consumer(