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 Type
    Method
    Description
    createInstance(String sagaIdentifier, Supplier<T> factoryMethod)
    Creates a new Saga instance.
    find(AssociationValue associationValue)
    Find saga instances of the given type that have been associated with the given associationValue.
    load(String sagaIdentifier)
    Loads a known Saga instance by its unique identifier.
  • Method Details

    • find

      Set<String> find(AssociationValue associationValue)
      Find saga instances of the given type that have been associated with the given associationValue.

      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

      Saga<T> load(String sagaIdentifier)
      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 return null in 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 null if no such saga exists
    • createInstance

      Saga<T> createInstance(String sagaIdentifier, Supplier<T> factoryMethod)
      Creates a new Saga instance. The returned Saga will delegate event handling to the instance supplied by the given factoryMethod.
      Parameters:
      sagaIdentifier - the identifier to use for the new saga instance
      factoryMethod - Used to create a new Saga delegate
      Returns:
      a new Saga instance wrapping an instance of type T