赞
踩
问题:在RocketMQ消费消息时,抛出如下问题:
-
- 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
-
- 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
- <dependency>
- <groupId>org.apache.rocketmq</groupId>
- <artifactId>rocketmq-spring-boot-starter</artifactId>
- <version>2.0.3</version>
- <exclusions>
- <exclusion>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
当前版本未将JackJson的转换加入其中:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。