MQ Cannot convert from [[B] to [] for GenericMessage

MQ消费端转换报错:
主要错误信息:
Caused by: org.springframework.messaging.converter.MessageConversionException: Cannot convert from [[B] to [com.***.***.***.***] for GenericMessage
[payload=byte[12], headers={amqp_receivedDeliveryMode=NON_PERSISTENT, amqp_receivedRoutingKey=ENT_***_NOTICE, amqp_deliveryTag=4, amqp_consumerQueue=ENT_***_NOTICE,
amqp_redelivered=false, id=cf822382-2a6e-8030-add4-b59bfa561e34, amqp_consumerTag=amq.ctag-2BJwxJlkUYKxiAkxPc67kA, timestamp=1559721028305}]


解决方法替换点mq默认的序列化器。
/**
* {@link org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration}
*  会自动识别
* @param objectMapper json序列化实现类
* @return mq 消息序列化工具
*/
@Bean 
public MessageConverter jsonMessageConverter(ObjectMapper objectMapper) {
return new Jackson2JsonMessageConverter(objectMapper);
}

 

posted @ 2019-06-05 17:27  江南叶少  阅读(5298)  评论(0编辑  收藏  举报