- Spring 5.0 Projects
- Nilang Patel
- 321字
- 2021-07-02 12:35:02
Publisher rules
Publisher has the following interface definition:
public static interface Publisher<T> {
public void subscribe(Subscriber<? super T> subscriber);
}
Rule number 1.1 says, the total number of onNext signaled by a Publisher to Subscriber must be less than, or equal to, the total number of elements requested by that Subscriber Subscription at all times. There are multiple facets to this definition here. Let’s try to analyze them one by one:
- First and foremost, there has to be a request for a message from Subscriber (total number → 1 - N) to Publisher. Therefore, Publisher cannot start sending messages to unsuspecting subscribers on its own as these subscribers might still be deciding when to start receiving messages. Furthermore, some might still be performing some initial tasks in order to start receiving the message.
- Secondly, only after the request is received by Publisher can it begin transmitting the messages to Subscriber. In response to the request for messages from Publisher, Subscriber receives Subscription. Now Subscriber can use Subscription to interact with Publisher and vice versa. How many messages Publisher should send is mentioned in Subscription so the requested messages by Subscribers should be less than or equal to that number [message count <= total number].
- Thirdly, Publisher cannot send more messages to Subscriber than requested by Subscriber.
These three points together form a part of the backpressure we mentioned when we began with Reactive Streams.
And yes, the count requested by Subscriber from Publisher is not binding on Publisher as per the other rule, not binding with respect to the count of messages. Publisher is allowed to send less than the requested count of messages from Subscriber. This can be described with the following.
推薦閱讀
- 物聯(lián)網(wǎng)網(wǎng)絡(luò)安全及應(yīng)用
- INSTANT PhpStorm Starter
- Hands-On Chatbot Development with Alexa Skills and Amazon Lex
- HCNA網(wǎng)絡(luò)技術(shù)
- 數(shù)字通信同步技術(shù)的MATLAB與FPGA實(shí)現(xiàn):Altera/Verilog版(第2版)
- Wireshark網(wǎng)絡(luò)分析就這么簡(jiǎn)單
- 數(shù)字調(diào)制解調(diào)技術(shù)的MATLAB與FPGA實(shí)現(xiàn):Altera/Verilog版(第2版)
- Learning Swift(Second Edition)
- 新手易學(xué):新手學(xué)淘寶開店
- AIoT應(yīng)用開發(fā)與實(shí)踐
- 移動(dòng)物聯(lián)網(wǎng):商業(yè)模式+案例分析+應(yīng)用實(shí)戰(zhàn)
- 網(wǎng)絡(luò)空間全球治理觀察
- 互聯(lián)網(wǎng)安全的40個(gè)智慧洞見(2016)
- 黑客與反黑工具使用詳解
- OSPF協(xié)議原理與功能拓展