当前位置:网站首页>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 .
边栏推荐
- LeetCode 第二十八天
- Redis (IX) - redis distributed lock
- 【SemiDrive源码分析】【驱动BringUp】41 - LCM 驱动 backlight 背光控制原理分析
- 2022危险化学品生产单位安全生产管理人员考试题模拟考试题库模拟考试平台操作
- 222. Number of nodes of complete binary tree
- 面试题:String类中三种实例化对象的区别
- ApacheCon Asia 预热直播之孵化器主题全回顾
- Towhee weekly model
- 阿里云服务器域名加端口网页不能访问问题记录
- 3381. Mobile keyboard (Tsinghua University postgraduate entrance examination machine test question)
猜你喜欢

手动从0搭建ABP框架-ABP官方完整解决方案和手动搭建简化解决方案实践

2022危险化学品生产单位安全生产管理人员考试题模拟考试题库模拟考试平台操作

C. Cypher

Restful fast request 2022.2.2 release, supporting batch export of documents

Process analysis of object creation

Program to change the priority of the process in LabVIEW

222. Number of nodes of complete binary tree

Function pointer and callback function

An online duplicate of a hidden bug

Golang sends email to the mail Library
随机推荐
Framework学习之旅:init 进程启动过程
Towhee weekly model
VR全景人淘金“小心机”(上)
【安卓小叙】Kotlin多线程编程(一)
Review in the sixth week
Lixia action | Yuanqi Digitalization: existing mode or open source innovation?
C # using sqlsugar updatable system to report invalid numbers, how to solve it? Ask for guidance!
【SemiDrive源码分析】【驱动BringUp】41 - LCM 驱动 backlight 背光控制原理分析
【OBS】circlebuf
Kotlin中lateinit和lazy的原理区别是什么
安装umi4阻碍一天的问题解决了
452页13万字现代智慧乡镇雪亮工程整体解决方案2022版
真正意义上的数字零售应当具有更加丰富的内涵和意义
电商系统结合商品秒杀活动,VR全景不断带来收益
Will this flinkcdc monitor all tables in the database? Or the designated table? I look at the background log. It monitors all tables. If it monitors
DataX无法连接对应的数据库(windows下可以,linux下失败)
小于等于K的最大子数组累加和
一文读懂 | 数据中台如何支撑企业数字化经营
A. Parkway Walk
Abstract intelligent extraction [based on Bert technology]