::: tip
2.0版本新增了网关模块，网关模块是 协议的解码编码，数据转发，数据计算，以及持久化存储功能集合。
:::

模块如下图所示

<img alt="网关模块架构图" src="./images/gateway/gateway01.png" style="border:1px solid #ccc;border-radius:6px;" loading="lazy" />

* gateway-boot 是网关的启动模块
* fastbee-mq 是网关的核心模块

## 一、网关的数据进入口

如下图所示：<br> <img alt="一、网关的数据进入口示意图" src="./images/gateway/gateway02.png" style="border:1px solid #ccc;border-radius:6px;" loading="lazy" />

## 二、网关的mq使用两种方式

1. redisChannel  + 本地队列
2. RockerMq

由下面的配置切换 ，默认使用redisChannel方式

```yml
#配置
cluster:
 enable: true
 type: redis
```

<img alt="二、网关的mq使用两种方式页面截图" src="./images/gateway/gateway03.png" style="border:1px solid #ccc;border-radius:6px;" loading="lazy" />

经过数据接口转发，然后根据channel分发数据，这里以redisChannel为例列举：<br>
注册所需通道：<br> <img alt="二、网关的mq使用两种方式页面截图" src="./images/gateway/gateway04.png" style="border:1px solid #ccc;border-radius:6px;" loading="lazy" />

消息进入通道后，进行消息分发：<br> <img alt="二、网关的mq使用两种方式页面截图" src="./images/gateway/gateway05.png" style="border:1px solid #ccc;border-radius:6px;" loading="lazy" />

消息进入消费队列，在消费队列中进行数据处理。<br> <img alt="二、网关的mq使用两种方式页面截图" src="./images/gateway/gateway06.png" style="border:1px solid #ccc;border-radius:6px;" loading="lazy" />
