Interface CommandEventPublisher<I>

Type Parameters:
I - the instance type as defined by the CommandHandler
All Superinterfaces:
EventPublisher
All Known Implementing Classes:
CommandEventCapturer

public interface CommandEventPublisher<I> extends EventPublisher
Extension to EventPublisher providing additional operations for publishing events relative to the Command.getSubject() being handled.

Implementations may defer event publication, typically to the end of a successful command execution, in order to publish all captured events atomically.

  • Method Details

    • publish

      default <E> I publish(E event)
      Publishes an event to the subject specified by Command.getSubject() and applies it to any assignable StateRebuildingHandlers participating in the command execution. No meta-data, i.e. an empty map, is published with the event.
      Type Parameters:
      E - the event type
      Parameters:
      event - the event to be published
      Returns:
      an updated or new instance with all events applied
    • publish

      <E> I publish(E event, Map<String,?> metaData)
      Publishes an event and its meta-data to the subject specified by Command.getSubject() and applies it to any assignable StateRebuildingHandlers participating in the command execution.
      Type Parameters:
      E - the event type
      Parameters:
      event - the event to be published
      metaData - the event meta-data to be published
      Returns:
      an updated or new instance with all events applied
    • publishRelative

      default <E> I publishRelative(String subjectSuffix, E event)
      Publishes an event to the subject specified by Command.getSubject() appended with the specified suffix and applies it to any assignable StateRebuildingHandlers participating in the command execution. No meta-data, i.e. an empty map, is published with the event.
      Type Parameters:
      E - the event type
      Parameters:
      subjectSuffix - the suffix to be appended to the Command.getSubject() currently executed, must not start with /
      event - the event to be published
      Returns:
      an updated or new instance with all events applied
    • publishRelative

      <E> I publishRelative(String subjectSuffix, E event, Map<String,?> metaData)
      Publishes an event and its meta-data to the subject specified by Command.getSubject() appended with the specified suffix and applies it to any assignable StateRebuildingHandlers participating in the command execution.
      Type Parameters:
      E - the event type
      Parameters:
      subjectSuffix - the suffix to be appended to the Command.getSubject() currently executed, must not start with /
      event - the event to be published
      metaData - the event meta-data to be published
      Returns:
      an updated or new instance with all events applied