Request-Response#

request-response messaging pattern

Request-Response Communication Model#

A bi-directional messaging pattern that enables direct communication between participants. Clients can send requests to servers through a service, with each individual request capable of receiving one or multiple streaming responses.

The request-response messaging pattern is ideal for scenarios requiring immediate feedback, data queries, or remote procedure calls. The use of shared memory enables efficient transfer of both request and response payloads.

The pattern is not suitable for cases where one-way communication suffices (publish-subscribe) or when data needs to persist for multiple consumers (blackboard).

Mechanism#

request-response messaging protocol

Request-Response over Shared Memory#

The RequestResponse messaging pattern is implemented using data structures in shared memory. Separate shared memory segments are used for sending requests and responses. The following structures are involved:

  1. Payload segment

    • A region in shared memory used to communicate payload data between participants

      • The request and response payload structures are often different

    • Clients have a payload segment to share requests with servers

    • Servers have a payload segment to share responses with clients

    • The organization of memory in the payload segment depends on the allocator used in the iceoryx2 deployment

      • This flexibility allows different deployments (e.g. desktop applications vs. safety-critical applications) to utilize a different strategy appropriate to their use-case

  2. Offset Channel

    • A channel for communicating the offsets of payloads within the payload segment

    • Each client-server pair has one offset channel for requests and one offset channel for responses

Further Reading#

Understand Events

See how the Event messaging pattern can be used to coordinate participants.

Event
Example: Request-Response Service (Rust)

See how to set up a basic RequestResponse service.

https://github.com/eclipse-iceoryx/iceoryx2/tree/main/examples/rust/request_response
Example: Dynamic Request-Response Service (Rust)

See how to set up a RequestResponse service with dynamic memory allocations.

https://github.com/eclipse-iceoryx/iceoryx2/tree/main/examples/rust/request_response_dynamic_data