@CommandHandler public void handle(Add cmd, CommandGateway gw) { apply(cmd); }
public Message(String messageContents) { identifier = UUID.randomUUID(); apply(new MessageCreatedEvent(messageContents)); }
@CommandHandlerInterceptor public void interceptAll(Object command) { apply(new AnyCommandInterceptedEvent(command.getClass().getName())); }
@CommandHandlerInterceptor public void interceptAll(Object command) { apply(new AnyCommandInterceptedEvent("NestedNested" + command.getClass().getName())); }
@CommandHandlerInterceptor public static void interceptAll(Object command, InterceptorChain chain) throws Exception { apply(new AnyCommandInterceptedEvent("StaticNestedNested" + command.getClass().getName())); chain.proceed(); }
@CommandHandlerInterceptor(commandNamePattern = ".*Nested.*") public void interceptAllMatchingPattern(Object command, InterceptorChain interceptorChain) throws Exception { apply(new AnyCommandMatchingPatternInterceptedEvent(command.getClass().getName())); interceptorChain.proceed(); }
public void delete() { AggregateLifecycle.apply(new StubDomainEvent()); AggregateLifecycle.markDeleted(); } }
@CommandHandler public void handle(InterceptorThrowingCommand command) { apply(new InterceptorThrewEvent(command.getId())); }
@CommandHandler public Book(CreateBookCommand cmd) { apply(new BookCreatedEvent(cmd.getBookId())); }
@CommandHandler public void handle(CreateParagraphCommand cmd) { apply(new ParagraphCreatedEvent(cmd.getBookId(), pageNumber, lastParagraphId + 1)); }
public void handle(MyCommand command, CommandGateway commandGateway) { apply(new MyEvent(aggregateIdentifier, command.startDescription())); if (command.getInnerCommand() != null) { commandGateway.sendAndWait(command.getInnerCommand()); } apply(new MyEvent(aggregateIdentifier, command.doneDescription())); }
@CommandHandler public MyAggregate(CreateMyAggregateCommand command, DeadlineManager deadlineManager) { apply(new MyAggregateCreatedEvent(command.id)); String deadlineName = "deadlineName"; String deadlineId = deadlineManager.schedule( Duration.ofMillis(DEADLINE_TIMEOUT), deadlineName, new DeadlinePayload(command.id) ); if (command.cancelBeforeDeadline) { deadlineManager.cancelSchedule(deadlineName, deadlineId); } }
@DeadlineHandler public void on(DeadlinePayload deadlinePayload, @Timestamp Instant timestamp) { assertNotNull(timestamp); apply(new DeadlineOccurredEvent(deadlinePayload)); }
@DeadlineHandler public void on(EntityDeadlinePayload deadlineInfo, @Timestamp Instant timestamp) { assertNotNull(timestamp); apply(new DeadlineOccurredInChildEvent(deadlineInfo)); } }
@CommandHandler public String handle(UpdateMyAggregateStateCommand command) { apply(new MyAggregateStateUpdatedEvent(command.getId(), command.getState())); return "aggregateUpdateResult"; }
@CommandHandler public void handle(MyNestedNestedCommand command) { apply(new MyNestedNestedEvent(command.getId(), command.getState())); }
@CommandHandler public void handle(MyNestedCommand command) { apply(new MyNestedEvent(command.getId(), command.getState())); }
@CommandHandler public void handle(UpdateCommand command, ConflictResolver conflictResolver) { conflictResolver.detectConflicts(Conflicts.payloadMatching(UpdatedEvent.class, u -> Objects.equals(command.getUpdate(), u.getUpdate()))); apply(new UpdatedEvent(command.getUpdate())); }
@CommandHandlerInterceptor public void intercept(ClearMyAggregateStateCommand command, InterceptorChain interceptorChain) throws Exception { if (command.isProceed()) { interceptorChain.proceed(); } else { apply(new MyAggregateStateNotClearedEvent(command.getId())); } }
@CommandHandler public void handle(UpdateParagraphCommand cmd) { Assert.isTrue(cmd.getParagraphId() == paragraphId, () -> "UpdatePageCommand reached the wrong paragraph"); apply(new ParagraphUpdatedEvent(cmd.getBookId(), cmd.getPageNumber(), paragraphId, cmd.getText())); }