Commands

Defining Commands

Commands represent actions that change the state of the system. They are typically initiated by the user or an external system and are processed by command handlers that contain the business logic.

Example Command:
@TopicInfo("customer-commands")
public interface CustomerCommand {

  class CreateCustomer implements CustomerCommand {
    @AggregateId
    private String customerId;
    private String firstName;
    private String lastName;
    // getters and setters
  }

}

Sending Commands

Commands are sent using the Command Gateway. It abstracts the complexity of sending commands to the appropriate handler.

Command Handling

Command handlers are responsible for processing incoming commands and producing events. A command handler typically validates the command, applies business logic, and emits one or more events.