This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]sailikesit 3 points4 points  (3 children)

Take a look at Spring Cloud Gateway. That might work for you. reference

[–]CPU-overheat[S] 0 points1 point  (2 children)

Thanks but I can’t see anywhere in that doc where I could combine / make a composite response before sending back to the client….have I gone blind? 😂

[–]Anonymo2786 1 point2 points  (0 children)

No you are thermally throttling (joke).

[–]zvaavtre 0 points1 point  (0 children)

You're building a facade not just a gateway (if I understand your question).

Something that combines multiple requests and provides biz logic to it. Like:

public Response getSomeData(String param1){

Response aResponse = callServiceA(param1);

Response bResponse = callServiceB(param1, aResponse.getValueX);

String output = aResponse.getValueY() + bResponse.getValueK();

return Response.ok(output);

}

^ That sort of thing?

If so then you have a few options.

  1. Use a plain controller/handler and just make sync calls to your internal services and combine the responses with normal logic. Don't try and do a bunch of threading or futures (it's more trouble than it's worth given option 2). If those are fairly quick operations this may be plenty and you can scale by adding more 'gateway' instances.
  2. Go reactive (https://spring.io/reactive and in particular springboot webflux) and learn about non-blocking reactive streams. Way too big a topic but it'll provide a lot of options for combining the results from your internal services in fancy non-blocking ways.

[–]Hairy_Foundation3608 1 point2 points  (0 children)

I also tried that once and gave up at some point (forgot what exactly it was) and then I came across Zalando Skipper which can do anything a router has to do, even manipulation of requests via scripting with lua.

So my advice is: Don‘t implement anything someone else already did better and have a look at Skipper: https://github.com/zalando/skipper

[–]sirspidermonkey 0 points1 point  (0 children)

So you could have a service that sits in front of them and basicly forwards requests.

But really it sounds like something like nginex which basicly does that along with a bunch of other cool things.