Processes place order commands and persists resulting events.
package com.example.eventsourcing.service.command;
import com.example.eventsourcing.domain.command.PlaceOrderCommand;
import eventsourcing.postgresql.domain.Aggregate;
import eventsourcing.postgresql.domain.command.Command;
import eventsourcing.postgresql.service.command.CommandHandler;
import jakarta.annotation.Nonnull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class PlaceOrderCommandHandler implements CommandHandler<PlaceOrderCommand> {
@Override
public void handle(Aggregate aggregate, Command command) {
// Add additional business logic here.
aggregate.process(command);
// Also, add additional business logic here.
// Read other aggregates using AggregateStore.
}
@Nonnull
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key