I'm developing a REST API with Java 11, Spring Boot and Spring Webflux.
I found myself having 3 different DB entities/documents (I'm using Reactive MongoDb) and therefore 3 repositories, and 3 services.
For the sake of simplicity let's call the entities E1, E2, E3.
I would like to create an API that works with the 3 services, although there is business logic that ties the 3 entities altogether. For example, a findAll on E1, requires to also do a findAll on E2 and then filter the first result based on the second result.
This gets even more complex when saving or updating, for example to save E2 I need to check if E1 exists, then check if there's another instance of E2 with E1's id, and so on and so forth.
My question is, is the Facade pattern a good idea? Is there a better alternative for this kind of scenario?
I considered splitting the architecture in 3 different microservices, one for each entity, but then I would need to aggregate the results and apply business logic at a higher level (either a 4th microservice that calls the other 3 services, or put that logic in an API Gateway) but I'm not sure if it is a good idea.
Aucun commentaire:
Enregistrer un commentaire