1. 程式人生 > 其它 >草雞RabbitMQ的小坑

草雞RabbitMQ的小坑

技術標籤:草雞java

今天在做RabbitMQ的時候,遇到了一個問題

Caused by: org.springframework.messaging.converter.MessageConversionException: Cannot convert from [[B] to [com.xxx.xxxx.data.center.entity.EhrOrganInfo] for GenericMessage [payload=byte[190], headers={amqp_receivedDeliveryMode=PERSISTENT, amqp_receivedRoutingKey=MQ_EHR_ORGANS, amqp_contentEncoding=UTF-8, amqp_deliveryTag=1, amqp_consumerQueue=MQ_EHR_ORGANS, amqp_redelivered=false, id=f4ed04ef-18b4-8ad8-21a0-a0a7871cc11c, amqp_consumerTag=amq.ctag-KUOrbMAp9Cr-su_53T9NsQ, contentType=application/json, __TypeId__=com.xuexin.xcloud.data.center.entity.EhrOrganInfo, timestamp=1579069885047}]

遇到這個問題,我先去看了程式碼,發現自己的消費者和生產者的資訊不一致,我就改了,然後就遇到這個問題。最後看了筆記,才發現那個反序列的config需要加在生產者和消費者,我只加了消費者那邊,失策了……

  @Bean
    public MessageConverter jsonMessageConverter(ObjectMapper objectMapper) {
        return new Jackson2JsonMessageConverter(objectMapper);
    }

我簡直太菜了