![f2fa35ebc536ed385e28a83030c09874.png](https://img-blog.csdnimg.cn/img_convert/f2fa35ebc536ed385e28a83030c09874.png)
本篇文章为系列文章,未读前几集的同学请猛戳这里:
哈喽沃德先生:Spring Cloud 系列之 Netflix Zuul 服务网关(一)zhuanlan.zhihu.com![bfd7a8038815c1490c78978548ddbc21.png](https://img-blog.csdnimg.cn/img_convert/bfd7a8038815c1490c78978548ddbc21.png)
![e9b83c175e0b34d842945b48280535cd.png](https://img-blog.csdnimg.cn/img_convert/e9b83c175e0b34d842945b48280535cd.png)
![ad3eee02b120ac43f8bf818d6393b6b8.png](https://img-blog.csdnimg.cn/img_convert/ad3eee02b120ac43f8bf818d6393b6b8.png)
本篇文章讲解 Zuul 和 Sentinel 整合,实现网关限流和容错以及高可用网关环境搭建。
Zuul 和 Sentinel 整合
![520a5ebad112dfb162333a1e78a37f76.png](https://img-blog.csdnimg.cn/img_convert/520a5ebad112dfb162333a1e78a37f76.png)
Sentinel 支持对 Spring Cloud Gateway、Netflix Zuul 等主流的 API Gateway 进行限流。
![b540d0076bc40403040238e391eb8333.png](https://img-blog.csdnimg.cn/img_convert/b540d0076bc40403040238e391eb8333.png)
官网文档:
- https://github.com/alibaba/spring-cloud-alibaba/wiki/Sentinel
- https://github.com/alibaba/Sentinel/wiki/网关限流#zuul-1x
网关限流
创建项目
创建 zuul-server-sentinel
项目。
添加依赖
单独使用添加 sentinel-zuul-adapter
依赖即可。
若想跟 Sentinel Starter 配合使用,需要加上 spring-cloud-alibaba-sentinel-gateway
依赖,同时需要添加 spring-cloud-starter-netflix-zuul
依赖来让 spring-cloud-alibaba-sentinel-gateway
模块里的 Zuul 自动化配置类生效。
同时请将 spring.cloud.sentinel.filter.enabled
配置项置为 false(若在网关流控控制台上看到了 URL 资源,就是此配置项没有置为 false)。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.