-
Notifications
You must be signed in to change notification settings - Fork 18
concurrency
ODENOS partly follows Actor Model for concurrency.
However, ODENOS guarantees message sequence (FIFO) for messages destined for a same RemoteObject instance, and supports synchronous messaging:
- Request/Response is synchronous
- Event is asynchronous
- (Synchronous Event is TBD)
Synchronous/asynchronous messaging
RemoteObject a RemoteObject b RemoteObject c RemoteObject d
| | | |
|<----- EVENT -------------------| |
| | |----- EVENT ----------->|
|------ REQUEST -------->|
Timer(30 sec) |
|<----- RESPONSE --------|
| |
Note: RESPONSE received after timeout (30sec) is dropped.
ODENOS assigns virtually a single thread to each actor (an instance of ODENOS RemoteObject class), and ODENOS's MessagaDispatcher put a mail in a mailbox for each actor.
Message sequence guarantee
FIFO incoming queue (mailbox) FIFO incoming queue (per JVM process)
--------- ---------
[RemoteObject instance] <-- o o o o o <------- o o o o o <------- messaging bus
| --------- ---------
| [MessageDispatcher]
| FIFO outgoing queue (per JVM process)
| ---------
+--------------------------------> o o o o o --------> messaging bus
---------
Messaging within a same JVM process does not use the messaging bus (i.e., Redis) at all. Request breaks into the FIFO incoming queue and Request/Response is performed using the sender's thread. On the other hand, EVENT is sent to a loopback interface and put in the mailbox.
FIFO incoming queue (mailbox) FIFO incoming queue (per JVM process)
--------- ---------
[RemoteObject instance] <-- o o o o o <------- o o o o o <------- messaging bus
| ^ --------- --------- ^
| | [MessageDispatcher] |
| | FIFO outgoing queue (per JVM process)
| | --------- |
+------------|-------------------> o o o o o ------|-> messaging bus
| --------- |
Request/Response |
| |
[RemoteObject instance]<-+ |
[RemoteObject instance]--- Event ------------------------------+
Although Actor Model is thought of as a very old technique for concurrency and linear scalability (e.g., a similar technique was used by central office switches (Telephony) some ten years ago), relatively new languages such as Scala adopted the model.
Since ODENOS supports multi-languages (Java, Python, Ruby...), is uses Redis as a messaging bus and ODENOS-original Actor Model implementation.