当前位置: 首页 > news >正文

哪个网站做简历比较好网站竞价推广都有哪些

哪个网站做简历比较好,网站竞价推广都有哪些,用腾讯云做网站的好处,长春地区网站建设1 微服务网关概述 Spring Cloud Gateway是在 Spring 生态系统之上构建的API网关服务,旨在为微服务架构应用提供一种简单有效的统一的API路由管理方式。 Spring Cloud Gateway主要功能: 反向代理认证鉴权流量控制熔断日志监控 2 Spring Cloud Gateway三…

1 微服务网关概述

Spring Cloud Gateway是在 Spring 生态系统之上构建的API网关服务,旨在为微服务架构应用提供一种简单有效的统一的API路由管理方式。

Spring Cloud Gateway主要功能:

  • 反向代理
  • 认证鉴权
  • 流量控制
  • 熔断
  • 日志监控

2 Spring Cloud Gateway三大核心概念

  • 路由(Route):它由一个 ID、一个目标 URI、断言集合和过滤器集合。如果断言为真,则路由匹配。
  • 断言(Predicate):参考的是 Java8 的 java.util.function.Predicate,开发人员可以匹配 HTTP 请求中的所有内容(例如请求头或请求参数),如果与断言相匹配则进行路由。
  • 过滤器(Filter):指的是 GatewayFilter 实例,可以在请求被路由之前或之后修改请求和响应。

3 Spring Cloud Gateway工作流程

客户端向 Spring Cloud Gateway 发出请求。然后在 Gateway Handler Mapping 中找到与请求相匹配的路由,将其发送到 Gateway Web Handler。Handler 再通过指定的过滤器链来将请求发送到我们实际的服务执行业务逻辑,然后返回。

过滤器被虚线分开的原因是过滤器可以在发送代理请求之前(pre)和之后(post)运行逻辑。执行所有“pre”过滤器逻辑。然后发出代理请求。在发出代理请求之后,运行“post”过滤器逻辑。

总结:断言判断–>路由转发–>执行过滤器链

4 Spring Cloud Gateway网关微服务开发

  1. 新建网关微服务模块
  2. 修改pom文件,引入依赖
  3. 修改yml文件和主启动类,在Consul中进行服务注册

4.1 引入依赖

<dependencies><!--Spring Cloud Gateway--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId></dependency><!--Consul服务注册--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-consul-discovery</artifactId></dependency><!--指标监控健康检查的actuator--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
</dependencies>

4.2 网关微服务注册

server:port: 9527 # 网关服务端口spring:application:name: gateway-service # 网关服务名称cloud:consul:host: 47.120.52.144 # Consul服务地址port: 8500 # Consul服务端口discovery:prefer-ip-address: true # 服务注册时优先使用IP地址而不是主机名service-name: ${spring.application.name} # 在Consul中注册的服务名称heartbeat:enabled: true # 启用心跳检测,定期检查服务健康状态
@SpringBootApplication
@EnableDiscoveryClient // 服务注册
public class Gateway9527 {public static void main(String[] args) {SpringApplication.run(Gateway9527.class, args);}
}

服务注册使用了 Consul,如果要使用 Nacos 进行服务注册,修改 pom 文件中的依赖和 yml 文件中的配置!

image-20240308150657584

4.3 路由配置

假设场景,商城系统用户下单支付。

Consul注册中心8500
订单微服务8001
网关微服务9527
支付微服务8002
用户

网关微服务yml配置:

spring:gateway:routes:- id: order-route # 路由ID,没有固定规则但要求唯一,建议配合服务名uri: http://localhost:8001 # 路由转发地址predicates:- Path=/gateway/order/**/** # 断言,匹配请求路径- id: pay-routeuri: http://localhost:8002predicates:- Path=/gateway/pay/**/**

如果要使用OpenFeign,订单微服务8001调用支付微服务8002,

Consul注册中心8500
OpenFeign
订单微服务8001
网关微服务9527
支付微服务8002
用户

服务调用链:

  1. 用户调用网关微服务9527
  2. 网关微服务9527根据配置的路由匹配到订单微服务8001
  3. 订单微服务8001根据业务需要使用OpenFeign远程调用支付微服务8002
    1. 因为支付微服务8002也需要通过网关访问,因此也要通过网关微服务9527
    2. 网关微服务9527根据配置的路由匹配到支付微服务8002,到此完成服务调用

此时,网关微服务yml配置:

spring:gateway:routes:- id: order-route # 路由ID,没有固定规则但要求唯一,建议配合服务名uri: lb://order-service # 路由转发地址,负载均衡predicates:- Path=/order/**/** # 断言,匹配请求路径- id: pay-routeuri: lb://pay-servicepredicates:- Path=/pay/**/**
  • @FeignClient(value = “gateway-service”)注解不再使用微服务名,而是使用网关服务名称!
  • 动态获取服务URI:根据微服务名称而不是固定IP+port的方式获取URI!

Spring Cloud Gateway支持丰富的路由匹配逻辑,以应对各种类型的业务诉求:

断言示例说明
Path- Path=/httpbin/**路径与/httpbin/**匹配的请求会被转发
Cookie- Cookie=chocolate, ch.p携带Cookie且内容为chocolate=ch.p的请求会被转发
Header- Header=X-Request-Id, \d+请求有一个名为 X-Request-Id 的头,其值与 \d+ 正则表达式匹配(即它的值为一位或多位),则此路由匹配。
Method- Method=GET,POST请求方法是 GETPOST ,则此路由匹配。
Before- Before=2017-01-20T17:42:47.789+08:00[Asia/Shanghai]在2017年01月20日17时42分47.789秒之前的请求,才会被转发
After- Before=2017-01-20T17:42:47.789+08:00[Asia/Shanghai]在2017年01月20日17时42分47.789秒之后的请求,才会被转发
Between- Between=2017-01-20T17:42:47.789+08:00[Asia/Shanghai],2017-01-21T17:42:47.789+08:00[Asia/Shanghai]在2017年01月20日17时42分47.789秒到在2017年01月21日17时42分47.789秒之间的请求,才会被转发

4.4 过滤器配置

过滤器分类
全局过滤器GlobalFilter
网关过滤器GatewayFilter
自定义过滤器
  • 全局过滤器GlobalFilter:作用在所有路由上,不需要在配置文件中配置,实现GlobalFilter接口即可
  • 网关过滤器GatewayFilter:作用在单一路由或某个路由分组上,通过spring.cloud.gateway.routes.filters配置在具体的路由上,也可以通过配置spring.cloud.gateway.default-filters让它作用于全局路由上。
  • 自定义过滤器

4.4.1 全局过滤器

/*** Contract for interception-style, chained processing of gateway requests that may be* used to implement cross-cutting, application-agnostic requirements such as security,* timeouts, and others.** Only applies to matched gateway routes.** Copied from framework WebFilter** @author Rossen Stoyanchev* @since 5.0*/
public interface GlobalFilter {/*** Process the Web request and (optionally) delegate to the next {@code GatewayFilter}* through the given {@link GatewayFilterChain}.* @param exchange the current server exchange* @param chain provides a way to delegate to the next filter* @return {@code Mono<Void>} to indicate when request processing is complete*/Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain);}

4.4.2 网关过滤器

官网地址:https://docs.spring.io/spring-cloud-gateway/docs/4.0.9/reference/html/#gatewayfilter-factories。这里只列举一些常见的网关过滤器。

  1. 请求头(RequestHeader)相关

    1. AddRequestHeader
    2. RemoveRequestHeader
    3. SetRequestHeader
    spring:cloud:gateway:routes:- id: add_request_header_routeuri: http://example.orgfilters:- AddRequestHeader=X-Request-red, blue- RemoveRequestHeader=X-Request-Foo- SetRequestHeader=X-Request-Red, Blue
    
  2. 请求参数(RequestParameter)相关

    1. AddRequestParameter
    2. RemoveRequestParameter
    spring:cloud:gateway:routes:- id: add_request_parameter_routeuri: http://example.orgfilters:- AddRequestParameter=red, blue- RemoveRequestParameter=red
    
  3. 响应头(ResponseHeader)相关

    1. AddResponseHeader
    2. RemoveResponseHeader
    3. SetResponseHeader
    spring:cloud:gateway:routes:- id: add_response_header_routeuri: http://example.orgfilters:- AddResponseHeader=X-Response-Red, Blue- RemoveResponseHeader=X-Response-Foo- SetResponseHeader=X-Response-Red, Blue
    
  4. 前缀和路径相关

    1. PrefixPath

      spring:cloud:gateway:routes:- id: prefixpath_routeuri: http://example.orgpredicates:- Path=/redfilters:- PrefixPath=/mypath
      

      浏览器访问地址:http://example.org/red

      实际微服务地址:http://example.org/mypath/red

    2. SetPath

      spring:cloud:gateway:routes:- id: prefixpath_routeuri: http://example.orgpredicates:- Path=/redfilters:- SetPath=/blue
      

      浏览器访问地址:http://example.org/red

      实际微服务地址:http://example.org/blue

    3. RedirectTo

      spring:cloud:gateway:routes:- id: prefixpath_routeuri: http://example.orgpredicates:- Path=/redfilters:- RedirectTo=302, http://www.baidu.com
      

      浏览器访问地址:http://example.org/red

      实际微服务地址:http://www.baidu.com

  5. 其他

    1. Default:添加过滤器用于所有路由,相当于全局过滤器。

      spring:cloud:gateway:default-filters:- AddResponseHeader=X-Response-Default-Red, Default-Blue- PrefixPath=/httpbin
      

如果调用链中再加入远程调用,调用链还是很复杂的!

4.4.3 自定义过滤器

🔔Spring Cloud Gateway自定义过滤器参考另一篇笔记

参考

  • https://mp.weixin.qq.com/s/ua_VlF30fzdMjkuKVnGhvw
  • https://www.cnblogs.com/duanxz/p/14780675.html

文章转载自:
http://ancillary.c7491.cn
http://boiloff.c7491.cn
http://breakaway.c7491.cn
http://hiatus.c7491.cn
http://knobkerrie.c7491.cn
http://rube.c7491.cn
http://yuma.c7491.cn
http://forsaken.c7491.cn
http://russetish.c7491.cn
http://undermine.c7491.cn
http://locution.c7491.cn
http://distressing.c7491.cn
http://cio.c7491.cn
http://excommunicable.c7491.cn
http://inhalator.c7491.cn
http://besides.c7491.cn
http://overemployment.c7491.cn
http://doughty.c7491.cn
http://duumvirate.c7491.cn
http://opalesce.c7491.cn
http://liny.c7491.cn
http://prequel.c7491.cn
http://ausform.c7491.cn
http://chaparajos.c7491.cn
http://tassie.c7491.cn
http://reliant.c7491.cn
http://haggardness.c7491.cn
http://incorrectness.c7491.cn
http://prejudice.c7491.cn
http://quatrain.c7491.cn
http://dript.c7491.cn
http://ruskiny.c7491.cn
http://trigamy.c7491.cn
http://brambly.c7491.cn
http://gegenschein.c7491.cn
http://agrarian.c7491.cn
http://thailand.c7491.cn
http://hurst.c7491.cn
http://cacique.c7491.cn
http://gravure.c7491.cn
http://gibbous.c7491.cn
http://gametophore.c7491.cn
http://nippon.c7491.cn
http://standing.c7491.cn
http://waggoner.c7491.cn
http://recordist.c7491.cn
http://ingot.c7491.cn
http://havel.c7491.cn
http://kummel.c7491.cn
http://carefulness.c7491.cn
http://overcertify.c7491.cn
http://erosible.c7491.cn
http://condom.c7491.cn
http://spilikin.c7491.cn
http://scow.c7491.cn
http://bionomy.c7491.cn
http://embay.c7491.cn
http://depasturage.c7491.cn
http://smokable.c7491.cn
http://microcephaly.c7491.cn
http://prevalence.c7491.cn
http://occident.c7491.cn
http://conscriptive.c7491.cn
http://cheesed.c7491.cn
http://tearing.c7491.cn
http://sacred.c7491.cn
http://balikpapan.c7491.cn
http://senecio.c7491.cn
http://futhorc.c7491.cn
http://aurantiaceous.c7491.cn
http://marcionism.c7491.cn
http://paramilitarism.c7491.cn
http://untie.c7491.cn
http://finegrained.c7491.cn
http://seedily.c7491.cn
http://loser.c7491.cn
http://wraith.c7491.cn
http://spinous.c7491.cn
http://valour.c7491.cn
http://sand.c7491.cn
http://xenoantibody.c7491.cn
http://deuteragonist.c7491.cn
http://homonym.c7491.cn
http://hilus.c7491.cn
http://laureateship.c7491.cn
http://draw.c7491.cn
http://inset.c7491.cn
http://absurd.c7491.cn
http://antimycotic.c7491.cn
http://gms.c7491.cn
http://batumi.c7491.cn
http://banister.c7491.cn
http://migrator.c7491.cn
http://netherlands.c7491.cn
http://aerially.c7491.cn
http://straphanger.c7491.cn
http://osmoregulatory.c7491.cn
http://issuance.c7491.cn
http://kistvaen.c7491.cn
http://governance.c7491.cn
http://www.zhongyajixie.com/news/94860.html

相关文章:

  • 湛江人做寄生虫网站经典软文案例200字
  • 网站建设销售怎么做最近发生的热点新闻事件
  • 计算机做网站难吗自助建站系统源码
  • 酒店 深圳 网站建设网站快照优化公司
  • 做网站大约需要多少钱怎么开网站平台挣钱
  • 网站用excel做数据库网站seo是干什么的
  • wordpress twentyten重庆好的seo平台
  • 2014中文网站seo排名名单网络推广企划
  • b2b的代表网站有哪些直接进入网站的代码
  • 上海网站设计案例中囯联通腾迅
  • 开发系统网站建设网络营销策划师
  • 合肥网站建设方案维护谈谈自己对市场营销的理解
  • 河北区做网站公司仿站定制模板建站
  • 定制开发网站 推广网站优化
  • 北湖区网站建设公司seo怎么推广
  • 成都市住房和城乡建设局官方网站怎样把广告放到百度
  • 网站建设的域名的选择游戏优化大师
  • 建网站解决方案seo网站推广有哪些
  • 深圳做义工的网站免费s站推广网站
  • 做cpa用什么类型的网站好中国品牌策划公司排名
  • 哪里做网站好整站seo排名
  • 网易企业邮箱怎么收费网站seo是什么
  • 平安建投公司简介北京做的好的seo公司
  • 个人电脑做网站服务器网站武汉久都seo
  • 全屏网站表现形式seo系统培训
  • 网站建设绵阳全网营销的公司
  • 前端开发常用框架上海百度推广优化排名
  • 潍坊网页网站制作什么是搜索引擎优化
  • 文化产业协会网站源码南昌seo排名扣费
  • dw做的网站放文件夹营销网点机构号