Reputation: 1518
I just moved to a new project, and it is a legacy code, having 15 microservices.
Problem is each service has 3-4 common classes, e.g. User.java
, Supplier.java
, Settings.java
. Whenever we need do any change in any of those classes in any of the microservices then we have to do that change in rest of other 14 apis as well, which is so tiring.
Is there any workaround for this problem?
Upvotes: 0
Views: 335
Reputation: 1893
Yes, we use RestTemplate to make api calls to our apis and have made each service expose a set of jars that defines the model, basic api calls on that model handling retries and stuff and expose each of them aligned with the api version.
Other services when import these and use them. Say they want user data they use make a function call to the method getUser and which in turn makes the api call fetches the data and respond back.
We try not to make breaking changes in apis and incrementally release new api version and new jar to be used by other system.
Note this is completely optional and its up to the service if they want to make use of the jars or if they want to make an api call directly.
Upvotes: 2