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.
Every operation takes the ProcessingContext it is invoked in. Axon Framework 4 resolved the ambient unit of
work from a thread local instead; Axon Framework 5 has no such global, so the context is passed explicitly. A
repository never creates a context: it is created by the event processor and handed down through the component that
invokes the Saga.
- Since:
- 3.0
- Author:
- Allard Buijze
-
Method Summary
Modifier and TypeMethodDescriptioncreateInstance(String sagaIdentifier, Supplier<T> factoryMethod, ProcessingContext context) Creates a new Saga instance.find(AssociationValue associationValue, ProcessingContext context) Find saga instances of the giventypethat have been associated with the givenassociationValue.load(String sagaIdentifier, ProcessingContext context) 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 withcontext- theProcessingContextthis lookup is part of- 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 loadcontext- theProcessingContextthe loaded Saga is managed in- 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 delegatecontext- theProcessingContextthe new Saga is managed in- Returns:
- a new Saga instance wrapping an instance of type
T
-