Menu Close

异常断电后Java项目启动报错:Failed to start RocketMQ push consumer

1. 故障描述

原本项目运行正常,因为停电原因,导致电脑异常关机,Java项目再次启动报如下错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderCashierGetConsumer' defined in file [D:\支付清算平台\TPP_GitLab\tpp-pay-clearing\tpp-pay\target\classes\com\hzsun\payclearing\pay\pay\order\OrderCashierGetConsumer.class]: Initialization of bean failed; nested exception is java.lang.RuntimeException: java.lang.IllegalStateException: Failed to start RocketMQ push consumer
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628) ~[spring-beans-5.3.27.jar:5.3.27]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.27.jar:5.3.27]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.27.jar:5.3.27]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.27.jar:5.3.27]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.27.jar:5.3.27]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.27.jar:5.3.27]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) ~[spring-beans-5.3.27.jar:5.3.27]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:920) ~[spring-context-5.3.27.jar:5.3.27]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.27.jar:5.3.27]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.12.jar:2.7.12]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731) [spring-boot-2.7.12.jar:2.7.12]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) [spring-boot-2.7.12.jar:2.7.12]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-2.7.12.jar:2.7.12]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) [spring-boot-2.7.12.jar:2.7.12]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) [spring-boot-2.7.12.jar:2.7.12]
    at com.hzsun.payclearing.pay.PayApplication.main(PayApplication.java:30) [classes/:na]
Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: Failed to start RocketMQ push consumer
    at org.apache.rocketmq.spring.autoconfigure.ListenerContainerConfiguration.registerContainer(ListenerContainerConfiguration.java:109) ~[rocketmq-spring-boot-2.2.3.jar:2.2.3]
    at org.apache.rocketmq.spring.annotation.RocketMQMessageListenerBeanPostProcessor.postProcessAfterInitialization(RocketMQMessageListenerBeanPostProcessor.java:55) ~[rocketmq-spring-boot-2.2.3.jar:2.2.3]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:455) ~[spring-beans-5.3.27.jar:5.3.27]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808) ~[spring-beans-5.3.27.jar:5.3.27]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.27.jar:5.3.27]
    ... 15 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to start RocketMQ push consumer
    at org.apache.rocketmq.spring.support.DefaultRocketMQListenerContainer.start(DefaultRocketMQListenerContainer.java:345) ~[rocketmq-spring-boot-2.2.3.jar:2.2.3]
    at org.apache.rocketmq.spring.autoconfigure.ListenerContainerConfiguration.registerContainer(ListenerContainerConfiguration.java:106) ~[rocketmq-spring-boot-2.2.3.jar:2.2.3]
    ... 19 common frames omitted
Caused by: org.apache.rocketmq.client.exception.MQClientException: readLocalOffset Exception, maybe fastjson version too low
See http://rocketmq.apache.org/docs/faq/ for further details.
    at org.apache.rocketmq.client.consumer.store.LocalFileOffsetStore.readLocalOffsetBak(LocalFileOffsetStore.java:222) ~[rocketmq-client-5.0.0.jar:5.0.0]
    at org.apache.rocketmq.client.consumer.store.LocalFileOffsetStore.readLocalOffset(LocalFileOffsetStore.java:200) ~[rocketmq-client-5.0.0.jar:5.0.0]
    at org.apache.rocketmq.client.consumer.store.LocalFileOffsetStore.load(LocalFileOffsetStore.java:64) ~[rocketmq-client-5.0.0.jar:5.0.0]
    at org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl.start(DefaultMQPushConsumerImpl.java:924) ~[rocketmq-client-5.0.0.jar:5.0.0]
    at org.apache.rocketmq.client.consumer.DefaultMQPushConsumer.start(DefaultMQPushConsumer.java:737) ~[rocketmq-client-5.0.0.jar:5.0.0]
    at org.apache.rocketmq.spring.support.DefaultRocketMQListenerContainer.start(DefaultRocketMQListenerContainer.java:343) ~[rocketmq-spring-boot-2.2.3.jar:2.2.3]
    ... 20 common frames omitted
Caused by: com.alibaba.fastjson.JSONException: syntax error, expect {, actual EOF, pos 318, fastjson-version 1.2.83
    at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:506) ~[fastjson-1.2.83.jar:na]
    at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.parseRest(JavaBeanDeserializer.java:1624) ~[fastjson-1.2.83.jar:na]
    at com.alibaba.fastjson.parser.deserializer.FastjsonASMDeserializer_6_OffsetSerializeWrapper.deserialze(Unknown Source) ~[na:na]
    at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:287) ~[fastjson-1.2.83.jar:na]
    at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:705) ~[fastjson-1.2.83.jar:na]
    at com.alibaba.fastjson.JSON.parseObject(JSON.java:394) ~[fastjson-1.2.83.jar:na]
    at com.alibaba.fastjson.JSON.parseObject(JSON.java:298) ~[fastjson-1.2.83.jar:na]
    at com.alibaba.fastjson.JSON.parseObject(JSON.java:588) ~[fastjson-1.2.83.jar:na]
    at org.apache.rocketmq.remoting.protocol.RemotingSerializable.fromJson(RemotingSerializable.java:45) ~[rocketmq-remoting-5.0.0.jar:5.0.0]
    at org.apache.rocketmq.client.consumer.store.LocalFileOffsetStore.readLocalOffsetBak(LocalFileOffsetStore.java:218) ~[rocketmq-client-5.0.0.jar:5.0.0]
    ... 25 common frames omitted

2. 产生原因

见:https://github.com/apache/rocketmq/issues/2322

3. 解决方案

把用户目录(C:\Users\用户名\.rocketmq_offsets)下文件删除,重启项目就好了!

file

附录

附录A. 相关联的文章

附录B. 参考