OS 007: Persistence with MicroStream

OS-007: Persistence with MicroStream

Date: 2020-11-13

Status

Implemented

Context

OS 007 head

The modules provided as tangly open source components are used in more complex applications. These applications require a reliable and performant persistence approach for their data.

In Java, everything is an object. In contrast, all databases come with their own specific data structure that is incompatible with Java objects.

This is called impedance mismatch.

As a consequence, a mapping is required, which means all data must be converted behind the scenes. Conversions are inefficient, lead to enormous loss of performance and latencies, and are linked to further serious disadvantages.

Decision

MicroStream was selected as persistence approach for the first versions of the ERP solution.

  1. Almost no impedance mismatch between the Java application and persistence store.

  2. An elegant approach to providing one persistence container for each bounded domain the same application.

  3. MicroStream has formally announced their software library will be published under an open source license.

  4. The library supports current versions of the JDK and all constructs of the language, including preview constructs.

  5. The support of the company is good. The answers are fast and professional.

Care will be taken to provide a fallback to another persistence solution if performance or licensing problems occur.

A huge advantage is the ease of migrating a java model from Microstream to JPA. Experience shows that the effort is often less than five working days [1].

EclipseStore

The decision to use MicroStream was a good approach. The library was moved to the Eclipse umbrella in 2024 and is now part of the Eclipse Foundation.

The library is now called Eclipse Store and is actively maintained and developed. Famous microservices frameworks like Quarkus and Helidon are using the library as one of their default persistence solutions.

A companion library provides seamless serialization of Java object graphs.

Consequences

  • Knowledge in MicroStream library [1] must be build-up.

  • Software design must be slightly adapted to the MicroStream approach.

    • A clear separation of data from functions is required.

    • Lambdas cannot currently be persisted. Therefore, all data containers with lambda variables must either be redesigned or declared as transient.

  • Work on a design enabling domain-driven design with MicroStream approach.

The MicroStream approach supports a very effective way to persist data. The effort to define storage and map Java objects to a persistent representation are minimal. This approach minimizes the costs for this functionality without impeding the quality or completeness of the solution.

Conventions

  1. Realm shall have a private data class to store all data to be persisted.

  2. The application must generate unique object identifiers. MicroStream does not provide functions in this area.

  3. Use specialized features of the library to implement Modern Java Constructs ADR.


1. Under the assumption that enough unit and integration tests are available to validate the migrated solution.