I am writing a server that will need to respond to lots of small web requests. Most of the requests will come with a small POST payload. Based on the contents of the payload, the server will either a) respond immediately, or b) forward the request as is to one of a pool of backend servers, waiting for a response and forwarding the response back to the client.
It looks like given the existing undertow code, I have good examples of how to forward requests to the backend. What isn't as clear is how to handle the getting the POST data. Is there a way of doing that without blocking?
Ideally, my handler flow would be:
1. Non-blocking request handler that makes sure all POST data is in.
2. A non-blocking handler that decisions based on content of POST data to
3a. Immediately return a response to the client (non-blocking).
or
3b. Dispatch to the worker pool to forward request to backend server and await response.
90% of my requests will go through path 3a, and I'd like that to be as quick as possible. When the server decides a request should go through 3b, only then should it go to the blocking worker pool.
Am I viewing this correctly? What are my options? Based on this threadÂ
it seems like an option could be to get the request channel in step 1 above? Its not clear to me how that would work.
Thanks,
Chris