当前位置:网站首页>网关Gateway的介绍
网关Gateway的介绍
2022-07-19 09:54:00 【华为云】
前言:
最近在学习微服务相关的知识,看了黑马的相关课程,将关于Gateway的知识又总结了一些,希望能帮到各位小伙儿们以及加深下自己的印象
如果文章有什么需要改进的地方还请大佬多多指教
小威先感谢大家的支持了
网关介绍
网关(Gateway)又称网间连接器、协议转换器。默认网关在网络层以上实现网络互连,是最复杂的网络互连设备,仅用于两个高层协议不同的网络互连。网关的结构也和路由器类似,不同的是互连层。网关既可以用于广域网互连,也可以用于局域网互连。
网关是一种充当转换重任的计算机系统或设备。使用在不同的通信协议、数据格式或语言,甚至体系结构完全不同的两种系统之间,网关是一个翻译器。与网桥只是简单地传达信息不同,网关对收到的信息要重新打包,以适应目的系统的需求。同层–应用层。
因此综上所述:
网关(Gateway)是将两个使用不同协议的网络段连接在一起的设备。
网关的作用就是对两个网络段中的使用不同传输协议的数据进行互相的翻译转换。
Gateway网关是我们服务的守门神,所有微服务的统一入口。
网关实现
在SpringCloud中网关的实现主要包括两种:gateway和zuul
Zuul是基于Servlet的实现,属于阻塞式编程。而SpringCloudGateway则是基于Spring5中提供的WebFlux,属于响应式编程的实现,具备更好的性能。
Gateway的使用
Gateway网关的使用步骤如下:
- 创建SpringBoot工程gateway,引入网关依赖
- 编写启动类
- 编写基础配置和路由规则
- 启动网关服务进行测试
第一步,引入依赖
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway</artifactId></dependency><!--nacos的服务依赖--><dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency>
第二步,编写启动类
import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublic class GatewayApplication { public static void main(String[] args) { SpringApplication.run(GatewayApplication.class, args); }}
边栏推荐
- 固定头部
- Use onedns to perfectly solve the optimization problem of office network
- Go language constants and operators
- 手写分布式配置中心(1)
- Detailed explanation of feign custom configuration
- 十年架构五年生活-02第一份工作
- NoSQL-Mongodb
- 在不切换分支的情况下查看不同分支中的文件
- Supply chain attacks are becoming increasingly serious. Microsoft's open source SBOM generation tool Salus
- Reading the paper: retreating atmosphere revolution for semantic image segmentation
猜你喜欢
巴比特 | 元宇宙每日必读:虚拟人热度减退,有的“出道即巅峰”,围观人群都散了?...
OpenHarmony littlefs文件系统存储结构与IO性能优化分析
30 times performance improvement -- implementation of MyTT index library based on dolphin DB
strcpy()
OSPF-LSA
Wechat official account pushes notification messages to fans (template messages)
什么是更适合中国企业的CRM选型标准?
Three application functions of digital sand table popular science
Early tuberculosis detection
Write "Hello, china." for domestic smart watches with C #
随机推荐
Go语言 流程控制
1305_ Basic queue function description of FreeRTOS
Nacos cluster setup (Reprint)
Mongodb startup error: child process failed, exited with 1
Blood spitting finishing nanny level series tutorial - playing Fiddler bag capturing tutorial (7) - Fiddler status panel -quickexec command line
postgresql 两个月份,如何计算一共有几个月?
vulnhub Me-and-My-Girlfriend-1
Experiment 2 rip comprehensive experiment
RK3399平台开发系列讲解(中断篇)13.16、request_irq的实现
Fully Convolutional Networks for Surface Defect Inspection in IndustrialEnvironment-论文阅读笔记
Get started with vite
Reading the paper: retreating atmosphere revolution for semantic image segmentation
在不切换分支的情况下查看不同分支中的文件
动态内存管理
How to deal with repeated consumption of MySQL data read by Flink
【Kingbase】数据类型格式化函数
Nacos configuration management - configuration hot update
【数据库】索引
Server check fail, please check server 192.168.11.13 ,port 9848 is available , error ={}
C leetcode notes 5-dynamic sum of one-dimensional array