Interface ChangeEventHandler<Command,​State,​ChangeEvent>


  • public interface ChangeEventHandler<Command,​State,​ChangeEvent>
    API May Change: Implement this interface and use it in DurableStateBehavior#withChangeEventHandler to store additional change event when the state is updated. The event can be used in Projections.

    The updateHandler and deleteHandler are invoked after the ordinary command handler. Be aware of that if the state is mutable and modified by the command handler the previous state parameter of the updateHandler will also include the modification, since it's the same instance. If that is a problem you need to use immutable state and create a new state instance when modifying it in the command handler.

    • Method Detail

      • updateHandler

        ChangeEvent updateHandler​(State previousState,
                                  State newState,
                                  Command command)
        Store additional change event when the state is updated. The event can be used in Projections.

        Parameters:
        previousState - Previous state before the update.
        newState - New state after the update.
        Returns:
        The change event to be stored.
      • deleteHandler

        ChangeEvent deleteHandler​(State previousState,
                                  Command command)
        Store additional change event when the state is updated. The event can be used in Projections.

        Parameters:
        previousState - Previous state before the delete.
        Returns:
        The change event to be stored.