Synchronous Responses
In a regular Wombat pipeline messages will flow in one direction and acknowledgements flow in the other:
However, Wombat has support for a number of protocols where this limitation is not the case.
For example, HTTP is a request/response protocol, and so our http_server
input is capable of returning a response payload after consuming a message from a request.
When using these protocols it’s possible to configure Wombat stream pipelines that allow messages to pass in the opposite direction, resulting in response messages at the input level:
Routing Processed Messages Back
It’s possible to route the result of any Wombat processing pipeline directly back to an input with a sync_response
output:
Using the above example, sending a request ‘foo bar’ to the path /post
returns the response ‘FOO BAR’.
It’s also possible to combine a sync_response
output with other outputs using a broker
:
Using the above example, sending a request ‘foo bar’ to the path /post
passes the message unchanged to the Kafka topic foo_topic
and also returns the response ‘FOO BAR’.
Returning Partially Processed Messages
It’s possible to set the state of a message to be the synchronous response before processing is finished by using the sync_response
processor. This allows you to further mutate the payload without changing the response returned to the input:
Using the above example, sending a request ‘foo bar’ to the path /post
passes the message ‘FOO BAR BAZ’ to the Kafka topic foo_topic
, and also returns the response ‘foo bar baz’.
However, it is important to keep in mind that due to Wombat’ strict delivery guarantees the response message will not actually be returned until the message has reached its output destination and an acknowledgement can be made.
Routing Output Responses Back
Some outputs, such as http_client
, have the potential to propagate payloads received from their destination after sending a message back to the input:
With the above example a message received from the endpoint /post
would be sent unchanged to the address http://localhost:4196/post
, and then the response from that request would get returned back. This basically turns Wombat into a proxy server with the potential to mutate payloads between requests.
The following config turns Wombat into an HTTP proxy server that also sends all request payloads to a Kafka topic: