一、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表达式创建自定义的接口