当前位置:   article > 正文

RocketMQ faultRocketMQListenerContainer.java:478) [ ]: convert failed. str:{}_.defaultrocketmqlistenercontainer:547 - convert fa

.defaultrocketmqlistenercontainer:547 - convert failed

问题:在RocketMQ消费消息时,抛出如下问题:

  1. 2022-05-22 20:28:58.551 INFO 1 --- [NettyClientPublicExecutor_1] [spread-business] [ ] faultRocketMQListenerContainer.java:478) [ ]: convert failed. str:{"orderId":1527590897781911552,"payChannel":2,"payState":1,"payTime":"2022-05-20T18:03:46.265","print":true,"state":100,"updateTime":"2022-05-20T18:03:46.265"}, msgType:class com.sssk.cloud.trade.dto.PaySuccessUpdateInfoDTO
  2. 2022-05-22 20:28:58.552 WARN 1 --- [NettyClientPublicExecutor_1] [spread-business] [ ] faultRocketMQListenerContainer.java:358) [ ]: consume message failed. messageExt:MessageExt [brokerName=null, queueId=2, storeSize=457, queueOffset=5, sysFlag=0, bornTimestamp=1653041026266, bornHost=/47.99.143.47:21644, storeTimestamp=1653041026281, storeHost=/10.100.13.166:10911, msgId=0A640DA600002A9F000000229F7CFB3A, commitLogOffset=148704656186, bodyCRC=1456887710, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message{topic='SAAS_SCAN_ORDER', flag=0, properties={TRACE_ON=true, MSG_REGION=cn-qingdao-publictest, UNIQ_KEY=C0A80FD000014E0E2F2A65B90CDA000C, TAGS=scan_pay_callback, INSTANCE_ID=MQ_INST_1748806876840792_BXkoYOPa}, body=[123, 34, 111, 114, 100, 101, 114, 73, 100, 34, 58, 49, 53, 50, 55, 53, 57, 48, 56, 57, 55, 55, 56, 49, 57, 49, 49, 53, 53, 50, 44, 34, 112, 97, 121, 67, 104, 97, 110, 110, 101, 108, 34, 58, 50, 44, 34, 112, 97, 121, 83, 116, 97, 116, 101, 34, 58, 49, 44, 34, 112, 97, 121, 84, 105, 109, 101, 34, 5

debug时,发现在调用转换器(MappingJackson2MessageConverter)时报错,JackJson不支持java8的时间类型

 错误如下:

Could not read JSON: Cannot construct instance of `java.time.LocalDateTime` (no Creators, like default constructor, exist): no String-argument constructor/factory method to deserialize from String value ('2022-05-20T17:41:38.955')
 at [Source: (String)"{"orderId":1527585238016139264,"payChannel":2,"payState":1,"payTime":"2022-05-20T17:41:38.955","print":true,"state":100,"updateTime":"2022-05-20T17:41:38.955"}"; line: 1, column: 70] (through reference chain: com.sssk.cloud.trade.dto.PaySuccessUpdateInfoDTO["payTime"])

解决方法:

1.改为JSON字符串发送,由消费者自行转换处理

2.更新jar

  1. <dependency>
  2. <groupId>org.apache.rocketmq</groupId>
  3. <artifactId>rocketmq-spring-boot-starter</artifactId>
  4. <version>2.0.3</version>
  5. <exclusions>
  6. <exclusion>
  7. <groupId>org.springframework.boot</groupId>
  8. <artifactId>spring-boot-starter-logging</artifactId>
  9. </exclusion>
  10. </exclusions>
  11. </dependency>

当前版本未将JackJson的转换加入其中:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/715390
推荐阅读
相关标签
  

闽ICP备14008679号