Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News MicroStream 7.0 Delivers Support for CDI

MicroStream 7.0 Delivers Support for CDI

This item in japanese

Lire ce contenu en français

MicroStream, a persistence engine for storing Java objects and documents, is able to load, update and persist object graphs partially and on demand in a performant and resource efficient way. MicroStream 7 provides integration with Contexts and Dependency Injection (CDI), the serializer logic as a standalone feature and logging support via SLF4J.

MicroStream supports various storage options such as AWS S3, Hazelcast, Kafka, MongoDB, Redis and various SQL databases. Some storage options are only available with an enterprise subscription. The getting started part of the reference manual provides instructions on using MicroStream with plain Java, or integrated into Helidon or Spring Boot.

This version introduces the MicroStream CDI extension, requiring a CDI 2.0 or higher implementation, via the microstream-integrations-cdi artifact. The extension is comparable to the existing Spring Boot and Helidon integrations. The MicroProfile Config specification is used to read the configuration from properties, supporting any MicroProfile runtime, or alternatively combine Java SE CDI with a MicroProfile Config implementation such as SmallRye Config.

The application should have one class annotated with @Storage, which connects to the MicroStream implementation:

public class CarStorage
    private final List<Car> carList = new ArrayList<>();

    public List<Car> findAll() {
        return this.carList;

    public void removeAll() {

    public void add(final Car car) {

The class annotated with @Storage is injected in a ApplicationScoped bean and data changing methods should be annotated with @Store:

public class CarStorageService {
    private CarStorage carStorage;

    public void addCar(Car car) {

    public void deleteCars() {

    public List<Car> findCars() {
        return carStorage.findAll();

MicroStream's CDI integration may also be used to store caching data:

private Cache<String, String> myCustomCache;

MicroStream uses a custom high performance serializer engine which is now exposed through an API and can be used standalone by adding the microstream-persistence-binary dependency. The entity types should be registered in order to make sure the unique number for each class is the same after deserializing the byte array:

CarPart porscheCarPart = new CarPart("wheel", 23.23);
Car porsche = new Car("Porsche", "911", List.of(porscheCarPart));

final SerializerFoundation<?> foundation = SerializerFoundation.New()
final Serializer<byte[]> serializer = Serializer.Bytes(foundation);
byte[] data = serializer.serialize(porsche);
Car deserializedCar = serializer.deserialize(data);
assertEquals("911", deserializedCar.getModel());
assertEquals(23.23, deserializedCar.getCarPartList().get(0).getPrice());

The new logging feature uses SLF4J as a logging facade and may be used together with logging frameworks such as Logback, by adding the logging framework dependency.

A custom handler for date and time instances on Android is available through the new microstream-persistence-binary-android artifact to solve the reflection challenges of recent Android versions.

Memory usage and release of memory are optimized and several bugs have been resolved.

First introduced in 2019, MicroStream was open-sourced with the release of MicroStream 5.0. This latest version is backwards compatible with MicroStream 6 and supported for free, for a period of twelve months for community users and the next major release is planned for April 2023. One of the planned new functionalities is cluster support for several MicroStream instances. Further details on the complete list of changes are available in the changelog.

About the Author

Rate this Article