@@ -0,0 +1,2517 @@
+package org.jeeventstore.jeecqrs.sagas;%0A%0Aimport de.redrainbow.care.common.sagas.SagaTimeoutRequest;%0Aimport de.redrainbow.care.common.sagas.SagaTimeoutRequestImpl;%0Aimport java.util.List;%0A%0A/**%0A * A saga is a long running process that reacts to events and issues commands.%0A * Sagas are aware of the notion of time and can request that they are%0A * notified again after a given interval.%0A * %3Cp%3E%0A * The flow is as follows:%0A * For each type of a saga, a listener subscribes to the event dispatching%0A * system and listens for domain events the saga is interested in.%0A * If an event of interest is received, the listener loads the corresponding%0A * saga from the %7B@link SagaRepository%7D and sends the event to the saga's event%0A * handler %7B@link #handle%7D.  The saga handles the event and may issue a number%0A * of commands as well as request timeouts, which allow to publish events%0A * after a specified interval.  The saga's new state is then saved into the%0A * repository again, the commands are sent through the command bus and the%0A * requested timeouts are sent to the %7B@link SagaTracker%7D, which issues%0A * the events after the specified timeout.%0A * %3Cp%3E%0A * The implementation%0A * of the saga is up to the client, but it is often a good idea to%0A * use some kind of state-machine approach to achieve idem-potency for events,%0A * since events can be delivered multiple times (the event dispatching system%0A * has an at-least-once guarantee).%0A * %3Cp%3E%0A * @param %3CC%3E   the type of commands to be sent%0A * @param %3CE%3E   the type of events to handle%0A */%0Apublic interface Saga%3CC, E%3E %7B%0A%0A    /**%0A     * Identifies the bucket to which the saga belongs.%0A     * %0A     * @return  the identifier%0A     */%0A    String bucketId();%0A%0A    /**%0A     * Uniquely identifies the saga within the bucket.%0A     * %0A     * @return  the identifier%0A     */%0A    String sagaId();%0A%0A    /**%0A     * Handles an event.%0A     * %0A     * @param event  the event to handle%0A     */%0A    void handle(E event);%0A%0A    /**%0A     * Gets the list of commands the saga issued while handling the event.%0A     * %0A     * @return  the list of issued commands%0A     */%0A    List%3CC%3E issuedCommands();%0A%0A    /**%0A     * Clears the list of issued commands.%0A     */%0A    void clearIssuedCommands();%0A%0A    /**%0A     * Gets the list of timeouts the saga requested while handling the event.%0A     * %0A     * @return  the list of requested timeouts.%0A     */%0A    List%3CSagaTimeoutRequest%3CE%3E%3E requestedTimeouts();%0A%0A    /**%0A     * Clears the list of requested timeouts.%0A     */%0A    void clearRequestedTimeouts();%0A    %0A%7D%0A

Add Saga interface