samedi 28 mars 2020

Calling Microserice using REST or dedicated client jar

When microservices need to talk with each other, the common practice will be to have some REST (or gRPC) communication.

I'm wondering what should be a better approach? (let's assume all services are in Java) -

  1. Each service is using a freestyle REST client (e.g. OkHttp)
  2. When service A needs to talk with service X, it has to include a dependency jar library of "service X client" that hides the network communication from service A.

Let's say this is our system - where service A uses services X and Y as its data resources:

   /-X
A--
   \-Y

Here are some cases:

New Functionality in X

If service X has new functionality for A, in both approaches there will be a need to update the code of A to support it and to add new HTTP calls. If we are using a dependency JAR, we will also need to create a new version of the jar.

New versions of X / Y

Versions update in X and Y, as long as they don't break the interface doesn't require any change in A - in both approaches.

Different HTTP library versions in X & Y clients

It is possible that X & Y client libraries will include different versions of the same HTTP client - this may cause dependency library conjunction in service A.

What is the best practice these days? I found this post and this post where each of them supports the other approach.

Aucun commentaire:

Enregistrer un commentaire