Package akka.javasdk.eventsourcedentity
Interface EventSourcedEntity.Effect.Builder<S,E>
- Type Parameters:
S
- The type of the state for this entity.
- Enclosing interface:
EventSourcedEntity.Effect<T>
public static interface EventSourcedEntity.Effect.Builder<S,E>
Construct the effect that is returned by the command handler. The effect describes next
processing actions, such as persisting events and sending a reply.
-
Method Summary
Modifier and TypeMethodDescriptionerror
(CommandException commandException) Create an error reply.Create an error reply.Persist a single event.Persist the passed events.persistAll
(List<? extends E> events) Persist the passed List of events.persistAllWithMetadata
(List<EventWithMetadata<? extends E>> events) Persist the passed List of events and additional metadata together with the events.persistWithMetadata
(E event, Metadata metadata) Persist a single event and additional metadata together with the event.reply
(T message) Create a message reply.Create a message reply.
-
Method Details
-
persist
Persist a single event. After this event is persisted, the event handlerinvalid reference
#applyEvent(E event)
-
persist
Persist the passed events. After these events are persisted, the event handlerEventSourcedEntity.applyEvent(E)
is called in order to update the entity state. Note, the event handler is called only once after all events are persisted. -
persistAll
Persist the passed List of events. After these events are persisted, the event handlerEventSourcedEntity.applyEvent(E)
is called in order to update the entity state. Note, the event handler is called only once after all events are persisted. -
persistWithMetadata
Persist a single event and additional metadata together with the event. After this event is persisted, the event handlerinvalid reference
#applyEvent(E event)
-
persistAllWithMetadata
EventSourcedEntity.Effect.OnSuccessBuilder<S> persistAllWithMetadata(List<EventWithMetadata<? extends E>> events) Persist the passed List of events and additional metadata together with the events. After these events are persisted, the event handlerEventSourcedEntity.applyEvent(E)
is called in order to update the entity state. Note, the event handler is called only once after all events are persisted. -
reply
Create a message reply.- Type Parameters:
T
- The type of the message that must be returned by this call.- Parameters:
message
- The payload of the reply.- Returns:
- A message reply.
-
reply
Create a message reply.- Type Parameters:
T
- The type of the message that must be returned by this call.- Parameters:
message
- The payload of the reply.metadata
- The metadata for the message.- Returns:
- A message reply.
-
error
Create an error reply. A short version of {effects().error(new CommandException(message))
}.- Type Parameters:
T
- The type of the message that must be returned by this call.- Parameters:
message
- The error message.- Returns:
- An error reply.
-
error
Create an error reply.CommandException
will be serialized and sent to the client. It's possible to catch it with try-catch statement orCompletionStage
API when using asyncComponentClient
API.- Type Parameters:
T
- The type of the message that must be returned by this call.- Parameters:
commandException
- The command exception to be returned.- Returns:
- An error reply.
-