Modifier and Type | Class and Description |
---|---|
static class |
JdbcSagaStore.Builder
Builder class to instantiate a
JdbcSagaStore . |
SagaStore.Entry<T>
Modifier | Constructor and Description |
---|---|
protected |
JdbcSagaStore(JdbcSagaStore.Builder builder)
Instantiate a
JdbcSagaStore based on the fields contained in the JdbcSagaStore.Builder . |
Modifier and Type | Method and Description |
---|---|
static JdbcSagaStore.Builder |
builder()
Instantiate a Builder to be able to create a
JdbcSagaStore . |
void |
createSchema()
Creates the SQL Schema required to store Sagas and their associations,.
|
void |
deleteSaga(Class<?> sagaType,
String sagaIdentifier,
Set<AssociationValue> associationValues)
Deletes a Saga with given
sagaType and sagaIdentifier and all its associations. |
Set<String> |
findSagas(Class<?> sagaType,
AssociationValue associationValue)
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)
Adds a new Saga and its initial association values to the store.
|
<S> SagaStore.Entry<S> |
loadSaga(Class<S> sagaType,
String sagaIdentifier)
|
void |
setSerializer(Serializer serializer)
Sets the Serializer instance to serialize Sagas with.
|
void |
updateSaga(Class<?> sagaType,
String sagaIdentifier,
Object saga,
AssociationValues associationValues)
Updates a given Saga after its state was modified.
|
protected JdbcSagaStore(JdbcSagaStore.Builder builder)
JdbcSagaStore
based on the fields contained in the JdbcSagaStore.Builder
.
Will assert that the ConnectionProvider
, SagaSqlSchema
and Serializer
are not
null
, and will throw an AxonConfigurationException
if any of them is null
.
builder
- the JdbcSagaStore.Builder
used to instantiate a JdbcSagaStore
instancepublic static JdbcSagaStore.Builder builder()
JdbcSagaStore
.
The SagaSqlSchema
is defaulted to an GenericSagaSqlSchema
, and the Serializer
to a
XStreamSerializer
.
The ConnectionProvider
is a hard requirement and as such should be provided. You can chose to
provide a DataSource
instead of a ConnectionProvider, but in that case the used ConnectionProvider will
be a DataSourceConnectionProvider
wrapped by a UnitOfWorkAwareConnectionProviderWrapper
.
JdbcSagaStore
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.
public 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 setSerializer(Serializer serializer)
serializer
- the Serializer instance to serialize Sagas withpublic void createSchema() throws SQLException
SQLException
- When an error occurs preparing of executing the required statementsCopyright © 2010–2019. All rights reserved.