'Role of Message passing in reactive systems
Following is an excerpt from here:
The foundation for a reactive system is message-passing, which creates a temporal boundary between components that allows them to be decoupled in time—this allows for concurrency—and space—which allows for distribution and mobility.
What exactly does this piece mean in terms of programming?
How does decoupling in time allow concurrency?
Solution 1:[1]
When you send a message to another (remote) component and you don't wait/block for their processing of the message or a response, your "main thread" continues. This makes it possible to send more messages or do other stuff.
myMessageChannelToSystemA.send(new StringMessage("Turn on the light"));
myMessageChannelToSystemB.send(new StringMessage("Open the windows"));
myMessageChannelToSystemC.send(new StringMessage("Close the door"));
In this case I told three components to do something. And because I don't wait for them to do it, they can fulfill the tasks in parallel.
In contrast
systemA.turnOnLight(); // blocking?
systemB.openWindows(); // blocking?
systemC.closeDoor(); // blocking?
may result in sequential processing (e.g. Remote Procedure Call).
Asynchronous message-passing is like sending emails. You can send several of them without waiting for the recipients to process/answer them.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Philipp |