RabbitMQ将对象作为消息发送

36 阅读1分钟

1.导入依赖

<dependency>
    <groupId>com.fasterxml.jackson.dataformat</groupId>
    <artifactId>jackson-dataformat-xml</artifactId>
</dependency>

2.添加配置

//amqp的MessageConverter,用于给消息对象序列化
@Bean
public MessageConverter messageConverter(){
    return new Jackson2JsonMessageConverter();
}

ps:对象对应的pojo实体类最好有无参构造