Package akka.javasdk.view
Class View
Object
akka.javasdk.view.View
A service that follows the Command Query Responsibility Segregation (CQRS) pattern.
Entities represent the command side where you change the state of your model in a strictly consistent and isolated manner. Views represent the query side of your application. Views are optimized for reads and allow you to query your model by fields other than the entity identifier.
A View implementation consists of two parts:
- One or more static public inner classes extending
TableUpdater
. Each concrete class is responsible for consuming events from one source, Event Sourced Entity events, Key Value Entity state changes or messages from a message broker Topic. and emitting a state that is stored in one table of the view. - One or more query methods annotated with queries for the tables of the view. Query methods
define the type of query parameters, if any as their input, and the type of the returned
result as the type parameter of
QueryEffect<T>
The query strings and table field types defines which fields should be indexed and how the query will be executed.
The query is executed by the runtime when a request is made to the View.
Concrete class must be annotated with ComponentId
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Not for user extension, instances are returned through factory method {queryResult()
}static interface
Not for user extension, instances are returned through factory methodqueryStreamResult()
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final <T> View.QueryEffect
<T> protected final <T> View.QueryStreamEffect
<T>
-
Constructor Details
-
View
public View()
-
-
Method Details
-
queryResult
- Returns:
- query effect for a query result that is a single response in the form of a row, an Optional row or a collection of rows projected into a single result type.
-
queryStreamResult
- Returns:
- query effect for a query result that can be streamed
-