zuul详解

RouteLocator 有三个实现类,在使用@EnableZuulServer 使用到
SimpleRouteLocator,CompositeRouteLocator 作为简单的路由定位,如开启的是@EnableZuulProxy 则使用到DiscoveryClientRouteLocator 及CompositeRouteLocator(该路由器只是组合)
@EnableZuulServer 生效的配置 ZuulServerAutoConfiguration ,非代理方式转发请求

@EnableZuulProxy生效的配置 ZuulProxyAutoConfiguration,动态代理路由转发请求
当DiscoveryClientRouteLocator实例不存在时创建其实例,因为DiscoveryClientRouteLocator是SimpleRouteLocator的子类,所有当该实例创建后,SimpleRouteLocator 不会再被创建,而简接装入ZuulHandlerMapping 是DiscoveryClientRouteLocator

1.从Dispatcher->ZuulHandlerMapping->ZuulController->ZuulServlet->ZuulRunner->FilterProcessor->ZuulFilter->PreDecorationFilter/CompositeRouteLocator(SimpleRouteLocator)
前面三个类调用过程是spring-mvc的内容不再分析,这里重点看ZuulServerlet后面的源码
2.静态路由将会把url及handler controler注册到ZuulHandlerMapping
ZuulHandlerMapping
动态更新路由信息

监听服务信息变化,以更可以动态变更路由信息

绕过dispatchServlet:

https://www.jianshu.com/p/f97096b8a39f

 

源码简单解析:

https://www.jianshu.com/p/0cfbc5779e5d

 

路由转发流程解析:

https://www.jianshu.com/p/5e5197e00d65

你可能感兴趣的:(zuul详解)