Search code examples
microservicescircular-dependency

Circular dependency of client libraries


I am working on 2 micro-services currently, microservice A includes microservice B's SDK to call B's API and access some entity classes. Similarly microservice B also includes microservice A's SDK and accesses microservice A's enitity classes.

Now I am facing one issue when I need to bump up the version of microservice B in microservice A and vice versa.

How should I solve this problem?


Solution

  • You've already broken the cardinal rule of microservices by tightly coupling the two services.

    The right answer here is going to be to refactor these services such that they properly and completely encapsulate functionality. That could involve combining them (if B is always and completely dependent on A, they may not really be separate services), splitting them out into more services, or just shifting responsibility.

    But, the path you're on with tight-coupled microservices leads to a distributed monolith which is unlikely to provide the benefits you're after (specifically including the co-dependent revision concern you mention here).

    Here's a good answer to a related question that might offer some more insight.