I am taking care of extraction of microservice out of a monolith written in Java with help of Spring Boot. We are planning to divide the whole monolith into a few smaller microservices.
I have to enable communication between the monolith and the new microservice as it needs entities from the new microservice (it has its own database) to perform certain actions. I thought of exposing REST endpoints but then I would have to duplicate entities.
Is it acceptable? If so, then REST controllers based in monolith which retrieve entities from microservice should be placed in the same layer as repositories? This solution would increase coupling which should be avoided, are there any other approaches?
I'll be grateful for any responses as well as articles which in your opinion may help here. Thank you in advance.