1.RabbitMQ架构图

-
publisher
:生产者,也就是发送消息的一方 -
consumer
:消费者,也就是消费消息的一方 -
queue
:队列,存储消息。生产者投递的消息会暂存在消息队列中,等待消费者处理 -
exchange
:交换机,负责消息路由。生产者发送的消息由交换机决定投递到哪个队列。 -
virtual host
:虚拟主机,起到数据隔离的作用。每个虚拟主机相互独立,有各自的exchange、queue
2.模拟收发消息
一.交换机

1.进去任意一个交换机,模拟生产者发送消息

2.由于没有消费者存在,最终消息丢失了,这样说明交换机没有存储消息的能力。

二.队列
1.添加两个队列:hello.queue1与hello.queue2


2.交换机与消息队列绑定

3.交换机再次发送消息


此时若有消费者监听了MQ的hello.queue1
或hello.queue2
队列,就会消费该消息。
3.数据隔离
1.用户管理:

这里的用户都是RabbitMQ的管理或运维人员。
-
Name
:itheima
,也就是用户名 -
Tags
:administrator
,说明itheima
用户是超级管理员,拥有所有权限 -
Can access virtual host
:/
,可以访问的virtual host
,这里的/
是默认的virtual host
当多个项目同时使用时,为了避免互相干扰,可以利用virtual host的隔离特性,将不同的项目隔离
2.virtual host
1.添加一个用户(此时没有设置virtual host)

2.切换用户为新建的用户

3.添加一个单独的virtual host


4.切换virtual host路径(此时便将/的消息队列隔离了)

