public abstract class CassandraReadSideProcessor<Event extends AggregateEvent<Event>>
extends Object
PersistentEntity
instances and update one or more tables in Cassandra that are optimized for queries.
The events belong to a AggregateEventTag
, e.g. all
persistent events of all Order
entities.Modifier and Type | Class and Description |
---|---|
class |
CassandraReadSideProcessor.EventHandlers |
class |
CassandraReadSideProcessor.EventHandlersBuilder
Mutable builder for defining event handlers.
|
Constructor and Description |
---|
CassandraReadSideProcessor() |
Modifier and Type | Method and Description |
---|---|
abstract AggregateEventTag<Event> |
aggregateTag()
The processed events belong to a
AggregateEventTag
that is specified by this method, e.g. |
java.util.concurrent.CompletionStage<java.util.List<com.datastax.driver.core.BoundStatement>> |
completedStatement(com.datastax.driver.core.BoundStatement stmt)
Convenience method to create an already completed
CompletionStage
with one BoundStatement . |
java.util.concurrent.CompletionStage<java.util.List<com.datastax.driver.core.BoundStatement>> |
completedStatements(java.util.List<com.datastax.driver.core.BoundStatement> stmts)
Convenience method to create an already completed
CompletionStage
with several BoundStatement . |
abstract CassandraReadSideProcessor.EventHandlers |
defineEventHandlers(com.lightbend.lagom.javadsl.persistence.cassandra.CassandraReadSideProcessor.EventHandlersBuilder builder)
Define the event handlers that are to be used.
|
java.util.concurrent.CompletionStage<java.util.List<com.datastax.driver.core.BoundStatement>> |
emptyStatements()
Convenience method to create an already completed
CompletionStage
with zero BoundStatement . |
java.util.concurrent.CompletionStage<java.util.Optional<java.util.UUID>> |
noOffset() |
abstract java.util.concurrent.CompletionStage<java.util.Optional<java.util.UUID>> |
prepare(CassandraSession session)
First you must tell where in the event stream the processing should start,
i.e.
|
public abstract AggregateEventTag<Event> aggregateTag()
AggregateEventTag
that is specified by this method, e.g. all persistent events of all Order
entities.public abstract java.util.concurrent.CompletionStage<java.util.Optional<java.util.UUID>> prepare(CassandraSession session)
select
statement here. Use the CassandraSession
to get the stored offset.
Other things that is typically performed in this method is to create
prepared statements that are later used when processing the events.
Use CassandraSession.prepare(java.lang.String)
to create the prepared statements.
Return noOffset()
if you want to processes all events, e.g. when
starting the first time or if the number of events are known to be small
enough to processes all events.
public abstract CassandraReadSideProcessor.EventHandlers defineEventHandlers(com.lightbend.lagom.javadsl.persistence.cassandra.CassandraReadSideProcessor.EventHandlersBuilder builder)
builder
to define the event handlers. One handler for each event class.
A handler is a BiFunction
that takes the event and the offset as
parameters and returns zero or more bound statements that will be executed
before processing next event.public final java.util.concurrent.CompletionStage<java.util.List<com.datastax.driver.core.BoundStatement>> completedStatement(com.datastax.driver.core.BoundStatement stmt)
CompletionStage
with one BoundStatement
.public final java.util.concurrent.CompletionStage<java.util.List<com.datastax.driver.core.BoundStatement>> completedStatements(java.util.List<com.datastax.driver.core.BoundStatement> stmts)
CompletionStage
with several BoundStatement
.public final java.util.concurrent.CompletionStage<java.util.List<com.datastax.driver.core.BoundStatement>> emptyStatements()
CompletionStage
with zero BoundStatement
.public final java.util.concurrent.CompletionStage<java.util.Optional<java.util.UUID>> noOffset()