adam bien's blog

The Perfect JavaEE Microservice 📎

Microservices are a self-contained and easily understandable realization of domain logic, highly independent of each other.

The definition above could be shortened as: "Maximal Cohesion, Minimal Coupling" (MC/MC), which in turn defines a Java EE business component. A Java EE component is an ordinary Java package organized with the MC/MC idea in mind, ideally with predefined internal structure like e.g. BCE / ECB.

According to the above definition, a perfect JavaEE microservice is single ECB component within a WAR deployed on a single server/domain. In such a case you could release and redeploy individual components (aka microservices) independently. Direct method invocations between WARs are not possible, so the WARs are forced to use e.g. JAX-RS to communicate with each other.

Monolithic deployment of multiple components within a single WAR still remains the simplest possible solution for a mainstream project without any additional requirements. Unfortunately, simplest possible solutions are usually not buzzword-compatible :-).

[See also an in-depth discussion in the "Real World Java EE Patterns--Rethinking Best Practices" book (Second Iteration, "Green Book"), page 419 in, chapter "Entity Control Boundary (ECB)—The Lean Way"]

See you at Java EE Workshops at Munich Airport, Terminal 2 and particularly at Java EE 7 Microservices and javaeemicro.services.