I have multiple artifacts (applications) deployed on different hosts (let's call them A, B, and C for simplicity) and I am currently looking for some kind of integration pattern, because I need to reduce the number of calls to the backend, so that I don't need separate calls to A, B and C, but rather one call to D which collects all the information and returns it to the client. I think of it as some kind of aggregator application.
I have read Sam Newman's book about Microservices and I am trying to implement something which is in accordance to the pattern "Backend for frontends", which means that every channel (mobile, web) has its own RESTful interface. He also talks about internal calls, but not about implementation details.
I use Java (RestEasy) for all applications, and I thought about using Retrofit for sending internal calls, which could solve some of my problems. Are there any other frameworks I should review?
Moreover, I would like to have some kind of automatic re-routing in place and I don't know if this is the way to go. I try to explain it by an example: there is an endpoint GET /customer/username/sometool/instructions which can be consumed by verified users only. If a customer is not verified, the endpoint should return information about the upgrade which could be retrieved by calling GET /customer/username/verification. So I thought about different options:
- /customer/username/sometool/instructions returns an exception, the exception mapper reads the errorcode (something like "customer not verified") and exception mapper knows that it has to collect the information from /customer/username/verification -> downside: exception mapper will become almighty over time
- /customer/username/sometool/instructions checks if customer is verified already, and if not it calls /customer/username/verification and collects the information -> downside: adds logic to instructions endpoint that does not really belong to instructions
- an aggregator module that works with annotations which are intercepted before the MessageResponseWriter is invoked. Something like: @OnFailure(errorCode="notverified" invoke="/customer/username/verification") -> downside: again, aggregator will become almighty
How do you think this should be implemented?