Spring Boot&RabbitMQ:消息转换内容类型

时间:2019-06-19 14:26:30

标签: spring-boot rabbitmq msgpack

我们正在使用Spring Boot 2.1.3.RELEASE和RabbitMQ。 MessagePack用于序列化。

我们正在使用convertAndSend:

app.childclass:
    class: ChildClass
    arguments: ["Foo", "Bar", "Duck"]
    ...

并收到以下异常:

rabbitTemplate.convertAndSend("exchange", "routingKey", object);

这是引发异常的行:

java.lang.UnsupportedOperationException: null
    at org.msgpack.jackson.dataformat.MessagePackFactory.createGenerator(MessagePackFactory.java:102)
    at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3219)
    at org.springframework.amqp.support.converter.AbstractJackson2MessageConverter.createMessage(AbstractJackson2MessageConverter.java:259)
    at org.springframework.amqp.support.converter.AbstractMessageConverter.toMessage(AbstractMessageConverter.java:70)
    at org.springframework.amqp.support.converter.AbstractMessageConverter.toMessage(AbstractMessageConverter.java:58)
    at org.springframework.amqp.rabbit.core.RabbitTemplate.convertMessageIfNecessary(RabbitTemplate.java:1726)
    at org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:1048)
    at org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:1041)

是否可以将return getRequiredMessageConverter().toMessage(object, new MessageProperties()); 中的内容类型设置为MessageProperties?默认值为application/json

0 个答案:

没有答案