Contents

Command Handler

Command Handler is an object which receives commands, modifies the state of the application, and generates events if the modification was successful.

final class TaskAggregate
    extends Aggregate<TaskId, Task, TaskVBuilder> {
    ...
    @Assign
    TaskCreated handle(CreateTask cmd, CommandContext ctx) {
        return TaskCreated
                .vBuilder()
                .setId(cmd.getId())
                .setName(cmd.getName())
                .setOwner(ctx.getActor())
                .build();
    }
    ...
}

Aggregate is an example of such classes. Objects can be Aggregate, ProcessManager and others inheriting AbstractCommandHandler. All above-mentioned classes implement CommandHandler interface.

For more details, refer to Java section.

Top