Request-response messaging
You can send request messages directly to a client session, a set of client sessions, or a message path. The recipient of a message can respond to the request.
Concepts
- Request
- A message sent from one client session to another session, to a message path, or to a set of sessions.
- Response
- A message sent in reply to a request message.
- Data type
- Request and response messages can contain data of one of the following
types: JSON, binary, string, 64-bit integer, or double.
The response message is not required to be the same data type as the request it responds to.
- Message path
- The path used to address the request messages.
The message path is made up of path segments separated by the slash character (/). Each path segment can be made up of one or more Unicode characters.
- Handler
- An object registered by client session to handle requests sent on message paths in a specific branch of the path hierarchy, and to respond to those requests.
- Stream
- An object used by a client session to receive requests sent to that client session, and to respond to those requests.
- Session properties
- Properties assigned to a session, either by
the
Diffusion™
server
or by an authentication handler. These
properties can be used to select the set of sessions to send requests
to.
For more information, see Session properties.
Send request messages in the following ways:
Send requests to a message path
A client session with the
permission can send requests on a message path. The sending client session does not know which client session, if any, receives the request.A client session with the
permission can register a handler on a part of the topic tree. This client session receives any requests that are sent on message paths in that part of the topic tree and sends a response.For more information, see Sending request messages to a message path.
Send request messages to a specific client session
A client session with the
permission that knows the session ID of a client session can send requests through a message path to the known client session.The responding client must have a request stream registered against a message path to receive requests sent through that message path and respond to them.
For more information, see Sending request messages to a session.
Send request messages to a set of client sessions
A client session with the
permission can send requests through a message path to a filter that selects client sessions based on their session properties.The responding client session must have a request stream registered against a message path to receive and respond to requests sent through that message path.
For more information, see Sending request messages to a session filter.
Considerations when using request-response messaging
- The data type of the request is not required to match the data type of the response. For more information, see Typed requests and responses.
- Messaging can use message paths that are the same as topic paths with topics bound to them. However, there is no connection between messaging and topics. For more information, see Message path.
- Request-response messaging is cluster-aware. This means that a message handler attached to one server in a Diffusion cluster can route a message to any server within that cluster.