当前位置:网站首页>网关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); }}
边栏推荐
猜你喜欢
It costs millions of dollars to track the mobile location of people at home and abroad without authorization
学习黑客需要先了解哪些知识,零基础怎样掌握网络安全知识体系
php 零点定时任务,PHP Laravel定时任务Schedule【干货】
Some questions about deploying Ogg microservices
0055 PHP language introduction and HelloWorld
Mongodb security authentication
NGFW的用户认证
Magic curve of product development that PM must master
Mongodb startup error: child process failed, exited with 1
Server check fail, please check server 192.168.11.13 ,port 9848 is available , error ={}
随机推荐
dotnet 读 WPF 源代码笔记 渲染收集是如何触发
降噪效果提升6倍以上!将麦克风设计在耳机内部,这款无线降噪耳机不一般!
Some questions about deploying Ogg microservices
实验3 MGRE 综合实验
Panda3D绘制立方体
It costs millions of dollars to track the mobile location of people at home and abroad without authorization
. Net 7 adds the rate limiting function to easily limit the number of requests
Automatic metallic surface defect detection and recognition with revolutionary neuralnetworks
0055 PHP language introduction and HelloWorld
Isn't it too much to play Gobang in idea?
Kmeans handwriting implementation and sklearn interface
Automatic Metallic Surface Defect Detection and Recognition with Convolutional NeuralNetworks-论文阅读笔记
MongoDB启动报错 ERROR: child process failed, exited with 1
实验4 MGRE环境下的OSPF实验
c# LeetCode刷题笔记5- 一维数组的动态和
Is it really possible to make reports with zero coding?
【黑马早报】张小泉总经理就不当言论道歉;世纪佳缘回应多名高管“消失”;泡泡玛特市值缩水超千亿;抖音将关闭“圈子”功能...
Feign入门之快速实战
kmeans手写实现与sklearn接口
聊一聊 C# 后台GC 到底是怎么回事?