Spring rabbit消息消费,payload格式错误
Spring rabbit message consumption, payload wrong format
我正在像那样使用 rabbitmq 队列中的消息
@RabbitListener(queues = "#{'${rabbitmq.queues}'.split(',')}" )
public void processOrder(@Payload String data, @Header(AmqpHeaders.CONSUMER_QUEUE) String queue) {
我在记录器中打印的数据似乎是字节,它正在打印这样的值:116,104,114,116,104,114,116,104,114
我该怎么办,请怎么做?反序列化?
默认SimpleMessageConverter
只能处理String和序列化的Java对象。它不理解的任何内容类型都将作为 byte[].
返回
字符串的 content_type
应该是 text/plain
。
您的留言内容是什么?邮件是否有 content_type
属性?如果有,价值是多少?
如果是 JSON(和 application/json
),您需要一个 Jackson2JsonMessageConverter
,但我看到您期待的是字符串,所以我怀疑它只是缺失的 content_type
属性.
我正在像那样使用 rabbitmq 队列中的消息
@RabbitListener(queues = "#{'${rabbitmq.queues}'.split(',')}" )
public void processOrder(@Payload String data, @Header(AmqpHeaders.CONSUMER_QUEUE) String queue) {
我在记录器中打印的数据似乎是字节,它正在打印这样的值:116,104,114,116,104,114,116,104,114 我该怎么办,请怎么做?反序列化?
默认SimpleMessageConverter
只能处理String和序列化的Java对象。它不理解的任何内容类型都将作为 byte[].
字符串的 content_type
应该是 text/plain
。
您的留言内容是什么?邮件是否有 content_type
属性?如果有,价值是多少?
如果是 JSON(和 application/json
),您需要一个 Jackson2JsonMessageConverter
,但我看到您期待的是字符串,所以我怀疑它只是缺失的 content_type
属性.