-1

Context:

We have Java maven Multi Microservices Project. The structure for each microservice is a contracts package and a service package.

When we update a version of a specific microservice the versions-maven-plugin knows to replace the version in all the dependents poms. Once there is a change in one file of a service, the build system knows to run this service.

The Problem:

We have some contracts packages that depend on other contracts package that dependence on other contracts packages (and so on). So we have transitive dependencies and it doesn't work well with the versioning mechanism.

Example:

A contracts use B contracts B contracts use C contracts => A contracts use C contracts transitively = without defining it explicitly in the POM. => When C contracts change the build system runs only B and C microservices.

Questions:

  1. Does it make sense that one service's contracts includes another service's contracts?

There are cases where we have a class that is used across multiservices and then we put it in a common library.

There are cases where the class is shared between only 3 microservices so I am not sure it should be in common. Duplication per microservice sound like a bad design because the structure needs to be identical in all places.

  1. How to solve it the transitive dependencies issue technically without the programmer's awareness to define the dependency explicitly in the pom?
0

1 Answer 1

0
  1. Does it make sense that one service's contract includes another service's contract?

Honestly? No, it doesn't make for a good strategy for MS architectures.

There are cases where we have a class that is used across multiservices and then we put it in a common library.

Shared libraries are a form of coupling. Not the kind of coupling we use to resolve in the code base, it's a development life cycle coupling.

SDLC coupling is one of the main reasons that led companies to break monoliths, the need for decoupling development life cycles, change requests management, capacity to release often, perform fail-fast experiments, etc. MS architectures try to unlock impediments between development and business goals.

There are cases where the class is shared between only 3 microservices, so I am not sure it should be in common. Duplication per microservice sound like a bad design because the structure needs to be identical in all places.

Take it a bit further. Suppose each MS is built in different programming languages or some services are products. What would you do to reuse code? Don't assume all services will be made upon the same stack (and versions) and at the same point in time. They are likely to go and come anytime and be implemented accordingly with the trends, needs and resources at hand.

MS don't reuse code, they reuse business capabilities. Whenever an MS needs specific knowledge or business capabilities, let it know sending a message or request, which is processed eventually.

  1. How to solve the transitive dependencies issue technically without the programmer's awareness to define the dependency explicitly in the pom?

By removing dependencies and adopting contract-agnostic interprocess communications.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.