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

NEW online workshop: WebStandards Igniter (online)

Airport MUC workshops: Java EE 7: Bootstrap, Effective, Architectures, Web, React and Angular, Testing and Microservices

Podcast: and newsletter:

A book about rethinking Java EE Patterns


what about the entities. Should they be packaged inside a jar and make available to all WAR's (microservices).

Posted by shekup on April 03, 2015 at 02:56 PM CEST #

Hi Adam:

Great post, as always. But I have the same concern as shekup. What about shared entities?

For instance, in a library app, we could have the loans microservices, and the inventory microservice. Where should the Book entity be implemented and packaged?


Posted by Guillermo Manjon on November 17, 2015 at 12:13 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments