Skip to content

Request-reply over pub/sub

Request-reply is implemented entirely in the client libraries. The API has no awareness of correlation ids or reply topics — it is a pure conduit, and the responder is always another service.

The requester stamps two CloudEvent extension attributes before publishing:

Attribute Meaning
correlationid opaque id, echoed back by the responder; the sole demux key
replytopic topic the responder should publish its reply to

Both are lowercase with no separators, per the CloudEvents extension-naming rule. The requester holds one persistent Subscribe stream per reply topic, shared across all in-flight calls, and matches incoming events on correlationid. It waits for the stream's response headers before publishing, so a reply cannot be missed in the gap between publishing and subscribing.

Per-call subscribe/unsubscribe is not an option here: it churns the shared Dapr subscription, and daprd's Redis Streams component leaks the underlying blocking XREADGROUP connection on unsubscribe until the pool is exhausted.

Use PublishWithResultAsync (.NET), publish_with_result_async (Python), or publishWithResult (TypeScript) rather than reimplementing this.

The topics and events it runs on: Events.