Request-Reply Communication¶
Overview¶
The Request/Reply communication pattern consists of two roles:
Server
(orLocalServer
), local server participantThis class is instantiated in the service-providing RSB process. Provided methods are registered by name and signature.
RemoteServer
, remote server participantThis class is instantiated in the service-using RSB process. EachRemoteServer
instance has one or more correspondingServer
instances, potentially in different processes, that provide the service in question. Client code calls methods on theRemoteServer
instance which cause methods of aService
instance to be called and perform the requested task.
For example:
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 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 handle absent and slow servers uniformly.
Server
¶
Conceptually, the Server
instance is the root of the following
object tree:
RemoteServer
¶
Conceptually, the RemoteServer
instance is the root of the
following object tree:
RemoteServer
- Scope:
SERVER-SCOPE
- Method
- more methods
- Scope:
Protocol¶
- Client code calls a method on a
RemoteServer
instance - The 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
Server
instance receives the event - The request event is dispatched to a handler for processing
- After processing, the reply informer of the method in the
Server
sends a reply event containing- The 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 occurred - The value
"REPLY"
in its method field - The event id of the request event in its causal vector
- The reply listener of the method in the
RemoteServer
receives the reply event - The 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++ | “0.14” branch of https://code.cor-lab.org/git/rsb.git.cpp at src/rsb/patterns/ |
Java | “0.14” branch of https://code.cor-lab.org/git/rsb.git.java at src/rsb/patterns/ |
Python | “0.14” branch of https://code.cor-lab.org/git/rsb.git.python at rsb/patterns/ |
Common Lisp | “0.14” branch of https://code.cor-lab.org/git/rsb.git.cl at src/patterns/request-reply |