spring cloud gateway 分析一 主流程和层次

一、debug的调用栈如下:

DispatcherHandler.handle(ServerWebExchange) line: 149

DefaultWebFilterChain.lambda$filter$0(ServerWebExchange) line: 79

1774625216.get() line: not available

MonoDefer<T>.subscribe(CoreSubscriber<? super T>) line: 45

MonoPeekTerminal<T>.subscribe(CoreSubscriber<? super T>) line: 61

MonoFlatMap$FlatMapMain<T,R>.onNext(T) line: 150

MonoZip$ZipCoordinator<R>(Operators$MonoSubscriber<I,O>).complete(O) line: 1083

MonoZip$ZipCoordinator<R>.signal() line: 247

MonoZip$ZipInner<R>.onNext(Object) line: 329

Operators$ScalarSubscription<T>.request(long) line: 1640

MonoZip$ZipInner<R>.onSubscribe(Subscription) line: 318

MonoJust<T>.subscribe(CoreSubscriber<? super T>) line: 54

MonoJust<T>(Mono<T>).subscribe(Subscriber<? super T>) line: 3080

MonoZip<T,R>.subscribe(CoreSubscriber<? super R>) line: 128

MonoFlatMap<T,R>.subscribe(CoreSubscriber<? super R>) line: 60

MonoDefer<T>.subscribe(CoreSubscriber<? super T>) line: 53

MonoDefer<T>.subscribe(CoreSubscriber<? super T>) line: 53

MonoPeekTerminal<T>.subscribe(CoreSubscriber<? super T>) line: 61

MonoPeekFuseable<T>.subscribe(CoreSubscriber<? super T>) line: 74

MonoDefer<T>.subscribe(CoreSubscriber<? super T>) line: 53

MonoDefer<T>.subscribe(CoreSubscriber<? super T>) line: 53

MonoOnErrorResume<T>.subscribe(CoreSubscriber<? super T>) line: 44

MonoOnErrorResume<T>.subscribe(CoreSubscriber<? super T>) line: 44

MonoOnErrorResume<T>.subscribe(CoreSubscriber<? super T>) line: 44

MonoOnErrorResume<T>(Mono<T>).subscribe(Subscriber<? super T>) line: 3080

MonoIgnoreThen$ThenIgnoreMain<T>.drain() line: 172

MonoIgnoreThen<T>.subscribe(CoreSubscriber<? super T>) line: 56

MonoPeekFuseable<T>.subscribe(CoreSubscriber<? super T>) line: 70

MonoPeekTerminal<T>.subscribe(CoreSubscriber<? super T>) line: 61

HttpServerOperations(ChannelOperations<INBOUND,OUTBOUND>).applyHandler() line: 380

HttpServerOperations.onHandlerStart() line: 398

522293148.run() line: not available

AbstractEventExecutor.safeExecute(Runnable) line: 163

NioEventLoop(SingleThreadEventExecutor).runAllTasks(long) line: 404

NioEventLoop.run() line: 465

SingleThreadEventExecutor$5.run() line: 884

DefaultLoopResources$EventLoop(Thread).run() line: not available

 

二、说明:从下到上依次是

1、netty的主事件循环

2、reactive接管网络事件的消息处理 HttpServerHandler extends ChannelDuplexHandler

3、通过reactive 内部的异步mono封装 HttpServerOperations把流程代理给spring的webflux

4、webflux 通过 org.springframework.web.server.handler.DefaultWebFilterChain 回调DispatcherHandler

 

三、几个jar包之间的关系

1、reactor-netty reactor对netty的封装

2、

reactor-core 核心flux和mono的封装

reactor-extra 数学、cache等的扩展

reactive-stream

3、spring-web 统一对http的基本数据结构和HttpHandler进行抽象

4、spring-webflux 基于reactor,用DispatcherHandler来映射请求到method

 

 

tips: @FunctionalInterface可以使用lambda表达式创建自定义的接口

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值