SpringBoot3整合RocketMQ问题处理
磁盘空间不够
报错如下:
org.apache.rocketmq.client.exception.MQBrokerException: CODE: 14 DESC: service not
available now. It may be caused by one of the following reasons: the broker's disk is
full [CL: 0.92 CQ: 0.92 INDEX: 0.92], messages are put to the slave, message store
has been shut down, etc. BROKER: 169.254.87.77:10911
解决办法:
- 清理磁盘空间
- 修改runbroker.cmd文件,增加如下内容:
set "JAVA_OPT=%JAVA_OPT% -server -Xms512m -Xmx512m -Xmn128m -Drocketmq.broker.diskSpaceWarningLevelRatio=0.99"
无法自动注入RocketMQTemplate
Field rocketMQTemplate in com.sks.crm.service.RocketMQProducerService required a bean
of type 'org.apache.rocketmq.spring.core.RocketMQTemplate' that could not be found.
原因:Springboot-3.0已经放弃了spring.plants自动装配,它被/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports所取代,添加这个文件是为了兼容。所以,在resources下创建META-INF,然后在META-INF下创建文件:org.springframework.boot.autoconfigure.AutoConfiguration.imports,然后在文件中添加org.apache.rocketmq.spring.autoconfigure.RocketMQAutoConfiguration即可。
RocketMQ的生产者和消费者都需要这个配置,不然有可能出现主题不存在订阅组,消费者无法监听到消息的问题。