Request-Reply Communication¶
Overview¶
The Request/Reply communication pattern consists of two roles:
local server participant (usually implemented as LocalServer class)
This participant is instantiated in the service-providing RSB process. Provided methods are registered by name and signature.
remote server participant (usually implemented as RemoteServer class)
This participant is instantiated in the service-using RSB process. Each
RemoteServerinstance has one or more correspondingLocalServerinstances, potentially in different processes, that provide the service in question. Client code calls methods on theRemoteServerinstance which cause methods of aLocalServerinstance to be called and perform the requested task.
For example:
![digraph rpc_example {
fontname=Arial
fontsize=11
node [fontsize=11,fontname=Arial]
edge [fontsize=11,fontname=Arial]
subgraph cluster_process1 {
label="process 1";
"remoteserver" [shape=rectangle];
}
subgraph cluster_process2 {
label="process 2";
"server" [shape=rectangle];
}
"remoteserver" -> "server" [label="request: call method foo"];
"server" -> "remoteserver" [label="reply: for foo call"];
}](_images/graphviz-214883c0dd41069bcc9b4e17f4c10f04f69c7b69.png)
Important
If a single service is provided by more than one server, requests will be processed in all servers, but the client will only receive one, arbitrarily selected, reply.
Conversely, if the service is not provided by any server, the request part of method calls is performed, but a reply is never received. This situation is indistinguishable from a server which takes an infinitely long time to process request and can therefore not be detected by the caller. However, timeouts can be used to handle absent and slow servers uniformly.
Participants¶
LocalServer
Conceptually, the
LocalServerinstance is the root of the following object tree:
RemoteServer
Conceptually, the
RemoteServerinstance is the root of the following object tree:
RemoteServer
Scope:
SERVER-SCOPEMethod
more methods
Protocol¶
Client code calls a method on a
RemoteServerinstanceThe request informer of the method publishes a request event containing
The argument of the method call as payload
The value
"REQUEST"in its method field
A record containing the event id of the request event is created for the method call
The call blocks until a reply event is received (see below)
The request listener of the method in a corresponding
LocalServerinstance receives the eventThe request event is dispatched to a handler for processing
After processing, the reply informer of the method in the
LocalServersends a reply event containingThe result of the processing as payload, if the processing succeeded without errors
The textual description of the error as payload, if an error occurred
A user-info item with key
rsb:error?and an arbitrary value, if an error occurredThe value
"REPLY"in its method fieldThe event id of the request event in its causal vector
The reply listener of the method in the
RemoteServerreceives the reply eventThe call record is located using the event id stored in the causal vector of the reply event
The blocking call is notified and
Examples¶
TODO: include examples or link to tutorial?
Implementations¶
Language |
File(s) |
|---|---|
C++ |
“1.0” branch of https://github.com/open-rsx/rsb-cpp at |
Java |
“1.0” branch of https://github.com/open-rsx/rsb-java at |
Python |
“1.0” branch of https://github.com/open-rsx/rsb-python at |
Common Lisp |
“1.0” branch of https://github.com/open-rsx/rsb-cl at |