Interface SagaStore<T>
- Type Parameters:
T- The saga type
- All Known Implementing Classes:
CachingSagaStore,InMemorySagaStore,JdbcSagaStore,JpaSagaStore,MongoSagaStore
public interface SagaStore<T>
Provides a mechanism to find, load update and delete sagas of type
T from an underlying storage like a
database.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceInterface describing a Saga entry fetched from a SagaStore. -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteSaga(Class<? extends T> sagaType, String sagaIdentifier, Set<AssociationValue> associationValues) Deletes a Saga with givensagaTypeandsagaIdentifierand all its associations.findSagas(Class<? extends T> sagaType, AssociationValue associationValue) Returns identifiers of saga instances of the givensagaTypethat have been associated with the givenassociationValue.voidinsertSaga(Class<? extends T> sagaType, String sagaIdentifier, T saga, Set<AssociationValue> associationValues) Adds a new Saga and its initial association values to the store.<S extends T>
@Nullable SagaStore.Entry<S> voidupdateSaga(Class<? extends T> sagaType, String sagaIdentifier, T saga, AssociationValues associationValues) Updates a given Saga after its state was modified, applying the association values added and removed since it was last stored.
-
Method Details
-
findSagas
Returns identifiers of saga instances of the givensagaTypethat have been associated with the givenassociationValue.- Parameters:
sagaType- The type of the returned sagasassociationValue- The value that the returned sagas must be associated with- Returns:
- A set of identifiers of sagas having the correct type and association value
-
loadSaga
Loads a known sagaSagaStore.Entryinstance with givensagaTypeand uniquesagaIdentifier.Due to the concurrent nature of Sagas, it is not unlikely for a Saga to have ceased to exist after it has been found based on associations. Therefore, a repository should return
nullin case a Saga doesn't exists, as opposed to throwing an exception.- Type Parameters:
S- the specific saga type returned- Parameters:
sagaType- The type of the returned saga entrysagaIdentifier- The unique identifier of the returned saga entry- Returns:
- The saga entry, or
nullif no such saga exists
-
deleteSaga
void deleteSaga(Class<? extends T> sagaType, String sagaIdentifier, Set<AssociationValue> associationValues) Deletes a Saga with givensagaTypeandsagaIdentifierand all its associations. For convenience all known association values are passed along as well, which has the advantage that the saga store is not required to keep an index of association value to saga identifier.- Parameters:
sagaType- The type of saga to deletesagaIdentifier- The identifier of the saga to deleteassociationValues- The known associations of the saga
-
insertSaga
void insertSaga(Class<? extends T> sagaType, String sagaIdentifier, T saga, Set<AssociationValue> associationValues) Adds a new Saga and its initial association values to the store.- Parameters:
sagaType- The type of the SagasagaIdentifier- The identifier of the Sagasaga- The Saga instanceassociationValues- The initial association values of the Saga
-
updateSaga
void updateSaga(Class<? extends T> sagaType, String sagaIdentifier, T saga, AssociationValues associationValues) Updates a given Saga after its state was modified, applying the association values added and removed since it was last stored.- Parameters:
sagaType- The type of the SagasagaIdentifier- The identifier of the Sagasaga- The Saga instanceassociationValues- The association values of the Saga, carrying the additions and removals to apply
-