Efficient upstream REST response pass-through #49475
Unanswered
jimbogithub
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Q. What is the best way to pass an upstream REST response to a downstream REST client? I'm looking for the most resource efficient approach.
Background:
Given
client -> restFacade -> shardedRestServicewe want to produce a response inshardedRestServiceand have it pass through therestFacadeback to theclient.shardedRestServiceis private so a redirect is not suitable.We had a pre Quarkus 3.25.x implementation that worked using the underlying
InputStreamalthough it had to be blocking as theInputStreamhad to be buffered. Since Quarkus 3.25.x it appears the buffering has been No-Op'd (https://github.com/quarkusio/quarkus/pull/48807/files#diff-3d3a89ac1de50e6e9389fa505c8ba2cfbe57234f664bd331821c6f2480361f71) so this solution no longer works (and was never ideal due to the buffering and blocking).Post Quarkus 3.25.x we are using
Uni<byte[]>as the response type for therestFacadeand the REST Client API that it uses to accessshardedRestService. This seems pretty good as it is non-blocking and does not need to materialise the underlying JSON data objects during the pass-through. It does presumably have to wait for the fullshardedRestServiceresponse before it can start forwarding to the client and does look like it needs to create a copy of the responsebyte[](fromBuffer) but fortunately they are not too large. This solution gets three green ticks in the DevUI.But is there a better way?
Beta Was this translation helpful? Give feedback.
All reactions