Synchronous Responses
Most pipelines flow in one direction: messages travel from input to output, and acknowledgements travel back. But request/response protocols like HTTP need to send a result back to the caller. Expanso Edge supports this with synchronous response patterns.
--------- Request -------->
Input (HTTP Server) -> Processors -> Output (Sync Response)
<--- Response (and ack) ---
This guide covers three patterns for returning responses:
- Route processed messages back to the caller
- Return partially processed messages while continuing the pipeline
- Propagate output responses from a downstream service
Route Processed Messages Back
Use the sync_response output to send the final processed message back to the input as a response.
input:
http_server:
path: /post
pipeline:
processors:
- mapping: root = content().uppercase()
output:
sync_response: {}
A POST request with the body foo bar to /post returns FOO BAR.
Combine with Other Outputs
Use a broker to fan out to multiple destinations while still returning a response. Each output can apply its own processors independently.
input:
http_server:
path: /post
output:
broker:
pattern: fan_out
outputs:
- kafka:
addresses: ["localhost:9092"]
topic: foo_topic
- sync_response: {}
processors:
- mapping: root = content().uppercase()
A request with foo bar sends the original message to Kafka and returns FOO BAR to the caller.
When combining multiple inputs with a broker, responses are always routed back to the original source of the message.
Return Partially Processed Messages
The sync_response processor captures the current message state as the response, then lets processing continue. This is useful when the response to the caller should differ from what reaches the final output.
input:
http_server:
path: /post
pipeline:
processors:
- mapping: root = "%v baz".format(content().string())
- sync_response: {}
- mapping: root = content().uppercase()
output:
kafka:
addresses: ["localhost:9092"]
topic: foo_topic
A request with foo bar:
| Destination | Value |
|---|---|
| HTTP response (captured after first processor) | foo bar baz |
| Kafka topic (after all processors) | FOO BAR BAZ |
The response is not returned to the caller until the message reaches its final output and is acknowledged. This preserves delivery guarantees but means response latency includes the full pipeline.
Propagate Output Responses
Some outputs, like http_client, can forward the response from a downstream service back to the input. This turns Expanso Edge into a processing proxy.
input:
http_server:
path: /post
output:
http_client:
url: http://localhost:4196/post
verb: POST
propagate_response: true
Messages received at /post are forwarded to http://localhost:4196/post, and the downstream response is returned to the original caller. Add processors to transform payloads in transit.
Proxy with Side-Channel Output
Combine response propagation with a broker to proxy requests while also logging or archiving the payload:
input:
http_server:
path: /post
output:
broker:
pattern: fan_out
outputs:
- kafka:
addresses: ["localhost:9092"]
topic: request_archive
- http_client:
url: http://localhost:4196/post
verb: POST
propagate_response: true
Every request is forwarded to the downstream service (with its response returned to the caller) and simultaneously archived to Kafka.
Next Steps
sync_responseoutput -- Full configuration referencesync_responseprocessor -- Capture partial responses mid-pipelinehttp_serverinput -- Configure the HTTP serverhttp_clientoutput -- Proxy and forward requestsbrokeroutput -- Fan out to multiple destinations