RequestReply » History » Version 5

« Previous - Version 5/9 (diff) - Next » - Current version
J. Moringen, 08/03/2011 08:25 AM
updated


Request/Reply Communication

Introduction

The Request/Reply communication pattern is provided by pair of classes called Server 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. Each RemoteServer instance has one or more corresponding Server instance, potentially in different processes, that provide the service in question. Client code calls methods on the RemoteServer instance which cause methods of a Service 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

  1. Client code calls a method on a RemoteServer instance
  2. The request informer of the method publishes an Event containing
    • The argument of the method call as payload
    • A user-info item with key ServerRequestId and the string representation of a UUID as value
    • The value "request" in its method field
  3. A record containing the above UUID event id is created for the method call
  4. The call blocks until a reply event is received (see below)
  5. The request listener of the method in a corresponding Server instance receives the Event
  6. The event is dispatched to a handler for processing
  7. After processing, the reply informer of the method in the Server sends an 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 isException and an arbitrary value, if an error occurred
    • A user-info item with key ServerRequestId and the value received in the user-info item of the same key in the request Event
      A user-info item with key rsb:reply and the id of the request event as value
    • The value "reply" in its method field
  8. The reply listener of the method in the RemoteServer receives the reply Event
  9. The call record is located using the value of the user-info item with key ServerRequestId rsb:reply
  10. The blocking call is notified and
    • returns the payload of the reply event, if a user-item with key rsb:error? is not present in the Event
    • signals an error, if a user-item with key rsb:error? is present in the Event

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