网站首页> 文章专栏> RabbitMQ-消息转换器
1,在生产中和消费中引入jackson包
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
并在某个地方注入bean,这里使用启动类
@Bean
public MessageConverter messageConverter(){
return new Jackson2JsonMessageConverter();
}
2,创建生产者
@Slf4j
@Component
public class SpringRabbitListener {
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = "object.queue",durable = "true"),
exchange = @Exchange(name = "object.fanout",type = ExchangeTypes.FANOUT)))
public void listenFanoutQueueMessage3(Map
3,消费者发送
@Test
void testSendObjectQueue() {
Map
代码很简单,可以尝试一下
2024-05-22 16:42:48 回复