Interface CommandContext
-
- All Superinterfaces:
ClientActionContext,Context,EffectContext,EntityContext,EventSourcedContext
public interface CommandContext extends EventSourcedContext, ClientActionContext, EffectContext
An event sourced command context.Methods annotated with
CommandHandlermay take this is a parameter. It allows emitting new events in response to a command, along with forwarding the result to other entities, and performing side effects on other entities.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description longcommandId()The id of the command being executed.java.lang.StringcommandName()The name of the command being executed.voidemit(java.lang.Object event)Emit the given event.longsequenceNumber()The current sequence number of events in this entity.-
Methods inherited from interface io.cloudstate.javasupport.ClientActionContext
fail, forward
-
Methods inherited from interface io.cloudstate.javasupport.Context
serviceCallFactory
-
Methods inherited from interface io.cloudstate.javasupport.EffectContext
effect, effect
-
Methods inherited from interface io.cloudstate.javasupport.EntityContext
entityId
-
-
-
-
Method Detail
-
sequenceNumber
long sequenceNumber()
The current sequence number of events in this entity.- Returns:
- The current sequence number.
-
commandName
java.lang.String commandName()
The name of the command being executed.- Returns:
- The name of the command.
-
commandId
long commandId()
The id of the command being executed.- Returns:
- The id of the command.
-
emit
void emit(java.lang.Object event)
Emit the given event. The event will be persisted, and the handler of the event defined in the current behavior will immediately be executed to pick it up.- Parameters:
event- The event to emit.
-
-