1、简介
Fanout,英文翻译是扇出。
2、 特点
3、设置队列
4、设置交换机
5、绑定队列
6、设置生产者
@Test
void testSendFanout() {
String exchangeName = "test.fanout";
String msg = "hello, everyone!";
rabbitTemplate.convertAndSend(exchangeName, null, msg);
}
7、设置消费者
@RabbitListener(queues = "fanout.queue1")
public void listenFanoutQueue1(String msg) throws InterruptedException {
System.out.println("消费者1 收到了 fanout.queue1的消息----:【" + msg +"】");
}
@RabbitListener(queues = "fanout.queue2")
public void listenFanoutQueue2(String msg) throws InterruptedException {
System.out.println("消费者2 收到了 fanout.queue2的消息====:【" + msg +"】");
}