RequestReply » History » Version 3
« Previous -
Version 3/9
(diff) -
Next » -
Current version
J. Moringen, 08/03/2011 04:28 AM
updated according to #458
Request/Reply Communication¶
Introduction¶
The Request/Reply communication pattern is provided by pair of classes calledServer
and RemoteServer
or similar:
Server
: This class is instantiated in the service-providing RSB process. Provided methods are registered by name and signature.RemoteServer
: This class is instantiated in the service-using RSB process. EachRemoteServer
instance has one or more correspondingServer
instance, 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.
Mapping to Event Concepts¶
Server
Representation¶
Conceptually, the Server
instance is the root of the following object graph:
Server
- Scope
- Method
- Name
- Request Listener
Scope:/SERVER-SCOPE/request/METHOD-NAME/
- Reply Informer
Scope:/SERVER-SCOPE/reply/METHOD-NAME/
- more methods
RemoteServer
Representation¶
Conceptually, the RemoteServer
instance is the root of the following object graph:
RemoteServer
- Scope
- Method
- Name
- Request Informer
Scope:/SERVER-SCOPE/request/METHOD-NAME/
- Reply Listener
Scope:/SERVER-SCOPE/reply/METHOD-NAME/
- A collection of in-progress method calls
- more methods
Communication¶
- Client code calls a method on a
RemoteServer
instance - The request informer of the method publishes an
Event
containing- The argument of the method call as payload
A user-info item with keyServerRequestId
and the string representation of a UUID as value- The value
"request"
in its method field
- A record containing the
above UUIDevent id 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 theEvent
- The event is dispatched to a handler for processing
- After processing, the reply informer of the method in the
Server
sends anEvent
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
isException
and an arbitrary value, if an error occurred A user-info item with keyServerRequestId
and the value received in the user-info item of the same key in the requestEvent
A user-info item with keyreplyTo
and the id of the request event as value- The value
"reply"
in its method field
- The reply listener of the method in the
RemoteServer
receives the replyEvent
- The call record is located using the value of the user-info item with key
ServerRequestId
replyTo
- The blocking call is notified and
- returns the payload of the reply event, if a user-item with key
isException
is not present in theEvent
- signals an error, if a user-item with key
isException
is present in theEvent
- returns the payload of the reply event, if a user-item with key
Implementations¶
Language | File(s) |
---|---|
C++ | source:trunk/cpp/core/src/rsb/patterns |
Java | source:trunk/java/core/src/rsb/patterns |
Python | source:trunk/python/core/rsb/patterns/__init__.py |
Common Lisp | source:trunk/cl/cl-rsb/src/patterns |