当前位置:网站首页>11. Zuul routing gateway
11. Zuul routing gateway
2022-07-27 04:05:00 【Bitter candy】
1. summary
Zuul It includes two main functions of request routing and filtering :
The routing function is responsible for forwarding external requests to specific microservice instances , It is the foundation of external access to the unified portal, while the filter function is responsible for intervening in the processing of requests , Is to implement request verification 、 Service aggregation and other functions .
Zuul and Eureka Integration , take Zuul Register yourself as Eureka Application under service governance , Simultaneously from Eureka Get messages from other microservices , That is to say, the access to microservices in the future is through Zuul Jump to get .
Be careful :Zuul The service will eventually register in Eureka
Provide = agent + route + Three functions of filtering
github: https://github.com/Netflix/zuul/wiki/Getting-Started
2. newly build Module modular microservicecloud-zuul-gateway-9527
2.1 Change pom
When you don't know which version to use with , Direct search Dalston.SR1.
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- zuul Routing Gateway -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zuul</artifactId>
<version>1.4.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
<version>1.4.0.RELEASE</version>
</dependency>
<!-- actuator monitor -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<!-- Hot deployment plug-in -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
2.2 Change yml
server:
port: 9527
spring:
application:
name: microservicecloud-zuul-gateway
zuul:
prefix: /atguigu
ignored-services: "*" # Ignore real service name
routes:
mydept.serviceId: cloud-payment-service
mydept.path: /path/**
eureka:
client:
register-with-eureka: true
fetchRegistry: true
service-url:
defaultZone: http://localhost:7001/eureka
# defaultZone: http://eureka7001.com:7001/eureka,http://eureka7002.com:7002/eureka # Cluster version
instance:
instance-id: zullgateway9527
prefer-ip-address: true
lease-renewal-interval-in-seconds: 1
lease-expiration-duration-in-seconds: 2
2.3 Start class
@EnableZuulProxy: Turn on zuul Gateway agent
@SpringBootApplication
@EnableZuulProxy
@EnableEurekaClient
@Slf4j
public class ZuulStartSpringCloudApp9527 {
public static void main(String[] args)
{
SpringApplication.run(ZuulStartSpringCloudApp9527.class, args);
log.info("===============ZuulStartSpringCloudApp9527 Successful launch ===============");
}
}
2.4 Route access mapping rules
before
http://localhost:9527/atguigu/cloud-payment-service/payment/get/3
zuul:
routes:
mydept.serviceId: microservicecloud-dept
mydept.path: /mydept/**
after
http://localhost:9527/atguigu/path/payment/get/3
adopt cloud-payment-service perhaps path All accessible .
The original real service name is ignored :
ignored-services: Single specific , Multiple can be used "*"
Set a uniform public prefix :
prefix: /atguigu
2.5 test
start-up cloud-eureka-server7001, start-up cloud-provider-payment8001, start-up microservicecloud-zuul-gateway-9527, take 8001 and 9527 All registered to eureka.
visit :http://localhost:9527/atguigu/path/payment/get/3 Normal return .
边栏推荐
- Summer meal | rich people are different from what you think (day 5) + power system power flow simulation (documents and matlab code)
- 【obs】动态码率:码率估算
- LeetCode 第二十八天
- 零基础小白也能懂的 Redis 数据库,手把手教你易学易用!
- [Android synopsis] kotlin multithreaded programming (I)
- Chapter 4 decision tree and random forest
- 基于风能转换系统的非线性优化跟踪控制(Matlab代码实现)
- Leetcode- > dichotomy (III)
- Prime factorization -- C (GCC) -- PTA
- First pass of routing strategy
猜你喜欢

Chapter 5 decision tree and random forest practice

First pass of routing strategy

356页14万字高端商业办公综合楼弱电智能化系统2022版

452页13万字现代智慧乡镇雪亮工程整体解决方案2022版

Use websocket to realize a web version of chat room (fishing is more hidden)

Chapter 4 decision tree and random forest

Towhee weekly model

04.在谷歌浏览器中安装模拟浏览器ChromeDriver的详细步骤

Plato farm brings a new experience to community users through the LAAS protocol elephant swap

Specific use of multithreading
随机推荐
分析一下CSDN大佬写的CAS,可重入锁, 非公平锁
DataX无法连接对应的数据库(windows下可以,linux下失败)
Alibaba cloud server domain name and port web page cannot access the problem record
Have you encountered the situation that CDC reads incomplete MySQL fields? How to deal with it?
Day 28 of leetcode
ApacheCon Asia 预热直播之孵化器主题全回顾
A. Parkway Walk
酷雷曼VR全景为你铺设创业之路
商业打假系列之第一百之--无聊的制度和管理流程真的可以扔进垃圾桶-顺便分析十几个无用的Unity游戏自检项目
mysql中case when返回多个字段处理方案
Read and understand | how data center supports enterprise digital operation
Feitengtengrui d2000 won the "top ten hard core technologies" award of Digital China
About the solution of using hyperbeach to appear /bin/sh: 1: packr2: not found
C. Cypher
VR全景人淘金“小心机”(上)
Leetcode- > 2-point search and clock in (3)
NFT数字藏品系统开发:小蚁数智帮助品牌一键上链发行NFT
LeetCode 第二十七天
Review in the sixth week
Chapter 4 decision tree and random forest