java reactor模式例子_回顾 Reactor 模式

Reactor

作为网络编程库的核心模式的 Reactor 模式是网络编程中的最常用的模式,反应器 Reactor 又名分派器 Dispatcher, 或通知器 Notifier, 重温一下 POSA2 是对这个模式的描述

语境

An event-driven application that receives multiple service requests simultaneously, but processes them synchronously and serially.

事件驱动的应用程序同时接收到多个服务请求, 但是对这些事件处理是同步和顺序的.

而 Reactor 模式是一种事件处理模式,用于处理通过一个或多个输入同时交付给服务处理程序的服务请求。 然后,服务处理程序对传入的请求进行多路分解,并将它们同步分发到关联的请求处理程序。

每个应用服务可能包含几个方法,它们被表示为一个个独立的事件处理器(event handler),用来负责分派特定服务的请求。

事件处理处理器(event handler) 的分派调度由一个初始化调度器(dispatcher)执行,这个调度器管理着注册过来的这些事件处理器。服务请求的多路分解由一个同步事件多路分解器(event demultiplexer)执行。

问题

Event-driven applications in a distributed system, particularly servers, must be prepared to handle multiple service requests simultaneously, even if those requests are ultimately processed serially within the application.

The arrival of each request is

本文链接:https://my.lmcjl.com/post/9432.html

展开阅读全文

4 评论

留下您的评论.