Package org.axonframework.modelling.saga
Interface SagaRepository<T>
- All Known Implementing Classes:
AnnotatedSagaRepository,LockingSagaRepository
public interface SagaRepository<T>
Interface towards the storage mechanism of Saga instances. Saga Repositories can find sagas either through the
values
they have been associated with (see
AssociationValue) or via their unique identifier.- Since:
- 3.0
- Author:
- Allard Buijze
-
Method Summary
Modifier and TypeMethodDescriptioncreateInstance(String sagaIdentifier, Supplier<T> factoryMethod) Creates a new Saga instance.find(AssociationValue associationValue) Find saga instances of the giventypethat have been associated with the givenassociationValue.Loads a known Saga instance by its unique identifier.
-
Method Details
-
find
Find saga instances of the giventypethat have been associated with the givenassociationValue.- Parameters:
associationValue- The value that the returned Sagas must be associated with- Returns:
- A Set containing the found Saga instances. If none are found, an empty Set is returned. Will never return
null.
-
load
Loads a known Saga instance by its unique identifier. 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 returnnullin case a Saga doesn't exists, as opposed to throwing an exception.- Parameters:
sagaIdentifier- The unique identifier of the Saga to load- Returns:
- The Saga instance, or
nullif no such saga exists
-
createInstance
Creates a new Saga instance. The returned Saga will delegate event handling to the instance supplied by the givenfactoryMethod.- Parameters:
sagaIdentifier- the identifier to use for the new saga instancefactoryMethod- Used to create a new Saga delegate- Returns:
- a new Saga instance wrapping an instance of type
T
-