0

I would like to know if it's possible to create a spring boot microservice between an old java 1.8 monolithic API and a Spring Boot Backend (React for the front but it doesn't matter).

Here is the idea:

RestController inside the monolithic API ---> Microservice (Springboot) ---> Back API (Springboot)

For the use case:

  1. Click on the button of API A
  2. Binding data to the RestController of the API B
  3. Send the same data to an API C

I don't think it's possible through a RestController due to the Cross Origin but it could be great to find a solution.

What do you think?

Adriaan Koster
  • 15,870
  • 5
  • 45
  • 60
Greg
  • 127
  • 1
  • 15

1 Answers1

0

TL;DR Assuming these are all synchronous remoting calls I think this should not pose too many problems, apart from maybe latency if that's an issue and possibly authentication.

The RestController in your Monolith A can call the REST API implemented by your Microservice B as long as it can reach that endpoint, and knows how to map/aggregate the data for it. The Microservice B can in turn call your Back API C.

I assume the calls will all be blocking, meaning each thread processing a request will be paused until a response is received. This means that the call to A will have to wait until B and C are all done with their processing and have sent their responses. This can add up (especially if these are all network hops to different servers). If this is a temporary set up to apply the strangler pattern to part of the monolith then the latency might not be an issue for the period in which calls are still routed through the monolith.

Cross origin resource sharing (CORS) is only a concern when retrieving content from a browser window as far as I know. In the described situation this should not be an issue. Any client calling Monolith A will not be aware of the components behind it. If one or more oof the three components are not under your control, or not managed/authenticated in the same way then you might run into some authentication challenges. For instance, the Microservice might require a JWT token which the Monolight might not yet provide. This would mean some tinkering to get the components to become friends in this respect.

Strangler pattern

Adriaan Koster
  • 15,870
  • 5
  • 45
  • 60
  • Thanks for your answer, it's very interesting. In my project, Controller A doesn't wait an answer. I just need its parameter to transmit them to the Controller B who will make the request to the database (at this point, it's the classical schema) but then, transmit the answer directly to the front C. So it's seems tricky to send data to a frontend C who has never send request to the backend B... – Greg Apr 20 '21 at 21:57
  • Frontend C? That was not in your question. I think one of us is confused. – Adriaan Koster Apr 21 '21 at 09:01
  • Yes, difficult to explain with only words, sorry: Clic on button on FRONT A ---- redirect to -----> FRONT C.....with parameters necessary to MICROSERVICE B to get datas. can I use MICROSERVICE B like a classical RestController with a @CrossOrigin with FRONT A but instead of displays datas on FRONT A, redirect to FRONT C via another RestController based on BACK C like this? : – Greg Apr 22 '21 at 06:09
  • Sorry I really don't understand what you mean – Adriaan Koster Apr 22 '21 at 19:24
  • Unfortunately, I can't post an sequency diagram, it would be more comprehensive. For the moment, I'll make a simple design pattern and hope I'll able to post a diagram to be more specific. – Greg Apr 23 '21 at 14:03