Stores

A projection keeps its read models in a store, chosen by the store annotation on the projection class. Each store annotation is also a Spring @Component, so the projection class is an ordinary bean; see The listener. The framework has three stores.

Comparison

In-memory JPA Query (experimental)

Annotation

@InMemoryProjection

@JpaProjection

@QueryProjection

Starter

every CQRS starter, such as spring-ddd-starter-cqrs

spring-ddd-starter-cqrs-jpa

spring-ddd-starter-cqrs-jdbc-query

Read models live

on each instance’s heap

in the application’s own entity table

in the framework’s tables in the application’s database

Survives a restart

no: rebuilt on every start

yes

yes

Instances

every instance, each with its own read models

shared by partition

shared by partition

Error handler

always halts

configurable with errorHandler

configurable with errorHandler

Can be an upstream

no

yes, while its read-model topic is written

yes

Repository

InMemoryProjectionRepository<T, ID>

the application’s own JpaRepository

QueryProjectionRepository<T, ID>

How to choose

Ad-hoc is not a store

A projection marked @AdHoc can also be materialized on demand, beside any store annotation; it keeps its store and keeps running from it. See Ad-hoc projections.

Serving read models over HTTP

To serve the read models of any store over HTTP, see Read models over HTTP.