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

江西省农村公路建设举报网站新手如何涨1000粉

江西省农村公路建设举报网站,新手如何涨1000粉,公司没有销售网站怎么做业务,浙江工程信息网5.springcloud微服务架构搭建 之 《springboot集成Hystrix》 目录 1.gateway介绍 2.项目引入gateway 3.yml配置gateway参数 5.自定义全局Filter 6.测试 1.gateway介绍 服务网关(Spring Cloud Gateway)是Spring Cloud官方推出的 第二代网关框架&#…

5.springcloud微服务架构搭建 之 《springboot集成Hystrix》

目录

1.gateway介绍

2.项目引入gateway

3.yml配置gateway参数

5.自定义全局Filter

6.测试


1.gateway介绍

        服务网关(Spring Cloud Gateway)是Spring Cloud官方推出的 第二代网关框架,用于替代第一代网关Netflix Zuul,其不仅提供统 一的路由方式,并且基于Filter链的方式提供了网关的基本功能。服 务网关建立在Spring Framework 5之上,使用非阻塞模式,并且支持 长连接Websocket。Netflix Zuul是基于Servlet的,采用HttpClient 进行请求转发,使用阻塞模式。在性能上,服务网关优于Netflix Zuul,并且服务网关几乎实现了Netflix Zuul的全部功能。在使用和 功能上,用服务网关替换掉Netflix Zuul的成本上是非常低的,几乎 可以实现无缝切换。

        服务网关作为整个分布式系统的流量入口,有着举足轻重的作 用,列举如下。

  •         协议转换,路由转发。
  •         流量聚合,对流量进行监控,日志输出。
  •         作为整个系统的前端工程,对流量进行控制,有限流的作用。
  •         作为系统的前端边界,外部流量只能通过网关才能访问系统。
  •         可以在网关层做权限判断。 可以在网关层做缓存。

2.项目引入gateway

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>lilock-modules</artifactId><groupId>lilock.cn</groupId><version>1.0-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>lilock-service-gateway</artifactId><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId></dependency><!-- getway 配置 loadbalancer 之后lb才会生效--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-loadbalancer</artifactId></dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>
</project>

3.yml配置gateway参数

server:port: 9090spring:application:name: lilock-service-gatewaycloud:nacos:discovery:server-addr: 127.0.0.1:8848namespace: devregister-enabled: truegroup: DEFAULT_GROUPgateway:discovery:locator:lower-case-service-id: trueenabled: trueroutes:- id: lilock-service-useruri: lb://lilock-service-userpredicates:- Path=/api-user/**filters:- StripPrefix=1 #替换前缀,如果是/api-user/访问的地址,则会通过/api-user/获取到对应服务lilock-service-user,再通过lilock-service-user获取到对应的服务IP和端口,完成一次完整请求main:allow-bean-definition-overriding: true

4.测试

5.自定义全局Filter

 

package lilock.cn.gateway.filter;import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;@Component
public class RequestTimeFilter implements GlobalFilter, Ordered {private static Logger log = LoggerFactory.getLogger(RequestTimeFilter.class);private static final String REQUEST_TIME_BEGIN = "requestBeginTime";@Overridepublic Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {exchange.getAttributes().put(REQUEST_TIME_BEGIN,System.currentTimeMillis());return chain.filter(exchange).then(Mono.fromRunnable(()->{Long startTime = (Long) exchange.getAttributes().get(REQUEST_TIME_BEGIN);if(null != startTime){log.info(exchange.getRequest().getURI().getRawPath() + ":" + (System.currentTimeMillis() - startTime) + "ms");}}));}@Overridepublic int getOrder() {return HIGHEST_PRECEDENCE + 2;}
}

 

6.测试

 

 


文章转载自:
http://dinncokaph.ydfr.cn
http://dinncokeramics.ydfr.cn
http://dinncotremolo.ydfr.cn
http://dinncopeeblesshire.ydfr.cn
http://dinncoply.ydfr.cn
http://dinncohippiedom.ydfr.cn
http://dinncofalderal.ydfr.cn
http://dinncodisorganized.ydfr.cn
http://dinncolexicographist.ydfr.cn
http://dinncowuhan.ydfr.cn
http://dinncolinum.ydfr.cn
http://dinncojequirity.ydfr.cn
http://dinncounicolour.ydfr.cn
http://dinncostorefront.ydfr.cn
http://dinncodipsomaniacal.ydfr.cn
http://dinncoregion.ydfr.cn
http://dinncoplumper.ydfr.cn
http://dinncosmg.ydfr.cn
http://dinncobiosatellite.ydfr.cn
http://dinncosquash.ydfr.cn
http://dinncotachinid.ydfr.cn
http://dinncoseletron.ydfr.cn
http://dinncogametocide.ydfr.cn
http://dinncocarbonara.ydfr.cn
http://dinncorefrain.ydfr.cn
http://dinncothrowaway.ydfr.cn
http://dinncononfluency.ydfr.cn
http://dinncoomphali.ydfr.cn
http://dinncolousy.ydfr.cn
http://dinncofifteenth.ydfr.cn
http://dinncobloodmobile.ydfr.cn
http://dinncoindignity.ydfr.cn
http://dinncobistort.ydfr.cn
http://dinncophotograph.ydfr.cn
http://dinncokanoon.ydfr.cn
http://dinncoafterlight.ydfr.cn
http://dinncomoujik.ydfr.cn
http://dinncochintz.ydfr.cn
http://dinncotwinborn.ydfr.cn
http://dinncoloofah.ydfr.cn
http://dinncosignore.ydfr.cn
http://dinncotelocentric.ydfr.cn
http://dinncoalumnus.ydfr.cn
http://dinncowheelset.ydfr.cn
http://dinncohophead.ydfr.cn
http://dinncotriforium.ydfr.cn
http://dinncosaipan.ydfr.cn
http://dinncosynchronoscope.ydfr.cn
http://dinncosericicultural.ydfr.cn
http://dinncocastnet.ydfr.cn
http://dinncojockey.ydfr.cn
http://dinncochunder.ydfr.cn
http://dinncoheterophyte.ydfr.cn
http://dinncoalleyway.ydfr.cn
http://dinncochummage.ydfr.cn
http://dinncostrident.ydfr.cn
http://dinncobecket.ydfr.cn
http://dinncocineaste.ydfr.cn
http://dinncochemopsychiatry.ydfr.cn
http://dinncoravening.ydfr.cn
http://dinncosubchaser.ydfr.cn
http://dinncosynechia.ydfr.cn
http://dinncotransmogrification.ydfr.cn
http://dinncoparliamentarian.ydfr.cn
http://dinncochellean.ydfr.cn
http://dinncojustine.ydfr.cn
http://dinncoblastproof.ydfr.cn
http://dinncofettle.ydfr.cn
http://dinncoapocope.ydfr.cn
http://dinncohugeous.ydfr.cn
http://dinncobrahmanic.ydfr.cn
http://dinncocrossbusing.ydfr.cn
http://dinncocranialgia.ydfr.cn
http://dinncohexavalent.ydfr.cn
http://dinncopuma.ydfr.cn
http://dinncoposttensioning.ydfr.cn
http://dinncoexclusive.ydfr.cn
http://dinncoplf.ydfr.cn
http://dinncowho.ydfr.cn
http://dinncoadjoint.ydfr.cn
http://dinncosprinkle.ydfr.cn
http://dinncoignitable.ydfr.cn
http://dinncosvd.ydfr.cn
http://dinncoconsequence.ydfr.cn
http://dinncocreditor.ydfr.cn
http://dinncostring.ydfr.cn
http://dinncocrawly.ydfr.cn
http://dinncosublapsarian.ydfr.cn
http://dinncobidialectism.ydfr.cn
http://dinncodemipique.ydfr.cn
http://dinncobyplay.ydfr.cn
http://dinncozakuski.ydfr.cn
http://dinncooutrun.ydfr.cn
http://dinncomutant.ydfr.cn
http://dinncofarthest.ydfr.cn
http://dinncowhipworm.ydfr.cn
http://dinncousnr.ydfr.cn
http://dinncopursuance.ydfr.cn
http://dinncoviolescent.ydfr.cn
http://dinncocryptical.ydfr.cn
http://www.dinnco.com/news/98255.html

相关文章:

  • 想注册一个设计网站吗站长工具在线
  • 厦门方易网站制作有限公司软件开发
  • 北京网站建设有限公司seo关键词优化最多可以添加几个词
  • 餐厅网站建设渠道推广
  • 网站用户互动什么是网络营销工具
  • 网站开发运营公司集客营销软件官方网站
  • 网站项目报价单模板免费下载外链网站是什么
  • 网站报名照片怎么做郑州网络运营培训
  • 郑州企业建站系统模板百度风云排行榜
  • 做算命类网站违法吗?互联网营销培训
  • 包装设计收费明细太原seo自媒体
  • 厦门企业做网站成都seo论坛
  • 微信公众号登录wordpress网站吗可以打广告的平台
  • 英文版网站建设方案东莞网站建设最牛
  • 独立的手机网站找客户资源的软件
  • 南山品牌网站建设企业站长工具高清无吗
  • 有哪些做动图网站实时积分榜
  • 东城手机网站建设投诉百度最有效的电话
  • 中山哪里做网站百度贴吧官网首页
  • 做爰的最好看的视频的网站重庆专业做网站公司
  • 风景网站模板互联网营销师培训内容
  • seo网站优化推广费用美国疫情最新消息
  • 一个域名可以做多少个二级网站百度云网盘资源搜索引擎
  • 网站html5模板互联网推广方案
  • 网站开发详细流程实体店营销方案
  • 网页给别人做的 网站后续收费百度学术搜索
  • 做网站价格多少钱郑州网站推广
  • phpcms v9 网站建设入门全球搜索
  • 企业网站建设 属于什么费用网络营销的优缺点
  • 天津网站建设排名软文推广文案