JpaSagaStore
which moved to
jakarta.@Deprecated public class JpaSagaStore extends Object implements SagaStore<Object>
SagaStore
. It uses an EntityManager
to persist the actual saga in a backing
store in serialized form.
After each operation that modified the backing store, EntityManager.flush()
is invoked to ensure the store
contains the last modifications. To override this behavior, see setUseExplicitFlush(boolean)
Modifier and Type | Class and Description |
---|---|
static class |
JpaSagaStore.Builder
Deprecated.
Builder class to instantiate a
JpaSagaStore . |
SagaStore.Entry<T>
Modifier | Constructor and Description |
---|---|
protected |
JpaSagaStore(JpaSagaStore.Builder builder)
Deprecated.
Instantiate a
JpaSagaStore based on the fields contained in the JpaSagaStore.Builder . |
Modifier and Type | Method and Description |
---|---|
static JpaSagaStore.Builder |
builder()
Deprecated.
Instantiate a Builder to be able to create a
JpaSagaStore . |
protected SagaEntry<?> |
createSagaEntry(Object saga,
String sagaIdentifier,
Serializer serializer)
Deprecated.
Intended for clients to override.
|
void |
deleteSaga(Class<?> sagaType,
String sagaIdentifier,
Set<AssociationValue> associationValues)
Deprecated.
Deletes a Saga with given
sagaType and sagaIdentifier and all its associations. |
Set<String> |
findSagas(Class<?> sagaType,
AssociationValue associationValue)
Deprecated.
Returns identifiers of saga instances of the given
sagaType that have been associated with the given
associationValue . |
void |
insertSaga(Class<?> sagaType,
String sagaIdentifier,
Object saga,
Set<AssociationValue> associationValues)
Deprecated.
Adds a new Saga and its initial association values to the store.
|
protected Set<AssociationValue> |
loadAssociationValues(javax.persistence.EntityManager entityManager,
Class<?> sagaType,
String sagaIdentifier)
Deprecated.
|
<S> SagaStore.Entry<S> |
loadSaga(Class<S> sagaType,
String sagaIdentifier)
Deprecated.
|
protected void |
removeAssociationValue(javax.persistence.EntityManager entityManager,
Class<?> sagaType,
String sagaIdentifier,
AssociationValue associationValue)
Deprecated.
Removes the given
associationValue of the saga with given sagaIdentifier and sagaType . |
protected String |
sagaEntryEntityName()
Deprecated.
Intended for clients to override.
|
protected Class<? extends SimpleSerializedObject<?>> |
serializedObjectType()
Deprecated.
Intended for clients to override.
|
void |
setUseExplicitFlush(boolean useExplicitFlush)
Deprecated.
Sets whether or not to do an explicit
EntityManager.flush() after each data modifying operation on the
backing storage. |
protected void |
storeAssociationValue(javax.persistence.EntityManager entityManager,
Class<?> sagaType,
String sagaIdentifier,
AssociationValue associationValue)
Deprecated.
Stores the given
associationValue of the saga with given sagaIdentifier and sagaType . |
void |
updateSaga(Class<?> sagaType,
String sagaIdentifier,
Object saga,
AssociationValues associationValues)
Deprecated.
Updates a given Saga after its state was modified.
|
protected JpaSagaStore(JpaSagaStore.Builder builder)
JpaSagaStore
based on the fields contained in the JpaSagaStore.Builder
.
Will assert that the EntityManagerProvider
and Serializer
are not null
, and will throw an
AxonConfigurationException
if any of them is null
.
builder
- the JpaSagaStore.Builder
used to instantiate a JpaSagaStore
instancepublic static JpaSagaStore.Builder builder()
JpaSagaStore
.
The EntityManagerProvider
and Serializer
are hard requirements and as such should be
provided.
JpaSagaStore
public <S> SagaStore.Entry<S> loadSaga(Class<S> sagaType, String sagaIdentifier)
SagaStore
SagaStore.Entry
instance with given sagaType
and unique sagaIdentifier
.
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.
protected Set<AssociationValue> loadAssociationValues(javax.persistence.EntityManager entityManager, Class<?> sagaType, String sagaIdentifier)
entityManager
- the entity manager instance to use for the querysagaType
- the saga instance classsagaIdentifier
- the saga identifierprotected void removeAssociationValue(javax.persistence.EntityManager entityManager, Class<?> sagaType, String sagaIdentifier, AssociationValue associationValue)
associationValue
of the saga with given sagaIdentifier
and sagaType
.entityManager
- the entity manager instance to use for the querysagaType
- the saga instance classsagaIdentifier
- the saga identifierassociationValue
- the association value to removeprotected void storeAssociationValue(javax.persistence.EntityManager entityManager, Class<?> sagaType, String sagaIdentifier, AssociationValue associationValue)
associationValue
of the saga with given sagaIdentifier
and sagaType
.entityManager
- the entity manager instance to use for the querysagaType
- the saga instance classsagaIdentifier
- the saga identifierassociationValue
- the association value to addpublic Set<String> findSagas(Class<?> sagaType, AssociationValue associationValue)
SagaStore
sagaType
that have been associated with the given
associationValue
.public void deleteSaga(Class<?> sagaType, String sagaIdentifier, Set<AssociationValue> associationValues)
SagaStore
sagaType
and sagaIdentifier
and 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.deleteSaga
in interface SagaStore<Object>
sagaType
- The type of saga to deletesagaIdentifier
- The identifier of the saga to deleteassociationValues
- The known associations of the sagapublic void updateSaga(Class<?> sagaType, String sagaIdentifier, Object saga, AssociationValues associationValues)
SagaStore
token
may be null
if the Saga is not tracking the
event store.updateSaga
in interface SagaStore<Object>
sagaType
- The type of the SagasagaIdentifier
- The identifier of the Sagasaga
- The Saga instanceassociationValues
- The initial association values of the Sagapublic void insertSaga(Class<?> sagaType, String sagaIdentifier, Object saga, Set<AssociationValue> associationValues)
SagaStore
token
may be null
if the Saga is not tracking the event store.insertSaga
in interface SagaStore<Object>
sagaType
- The type of the SagasagaIdentifier
- The identifier of the Sagasaga
- The Saga instanceassociationValues
- The initial association values of the Sagapublic void setUseExplicitFlush(boolean useExplicitFlush)
EntityManager.flush()
after each data modifying operation on the
backing storage. Default to true
useExplicitFlush
- true
to force flush, false
otherwise.protected SagaEntry<?> createSagaEntry(Object saga, String sagaIdentifier, Serializer serializer)
SagaEntry
.sagaIdentifier
- The identifier of the Sagasaga
- The Saga instanceserializer
- The serializer to serialize to the SagaEntry.getSerializedSaga()
SagaEntry
protected String sagaEntryEntityName()
protected Class<? extends SimpleSerializedObject<?>> serializedObjectType()
SerialzedSaga.class
SagaStore
storesCopyright © 2010–2024. All rights reserved.