Class View

Object
akka.javasdk.view.View

public abstract class View extends Object
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:

  1. 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.
  2. 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.

  • Constructor Details

    • View

      public View()
  • Method Details

    • queryResult

      protected final <T> View.QueryEffect<T> 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

      protected final <T> View.QueryStreamEffect<T> queryStreamResult()
      Returns:
      query effect for a query result that can be streamed