public static class JdbcEventStorageEngine.Builder extends BatchingEventStorageEngine.Builder
JdbcEventStorageEngine
.
The following configurable fields have defaults:
Serializer
defaults to XStreamSerializer
.EventUpcaster
defaults to an NoOpEventUpcaster
.PersistenceExceptionResolver
is defaulted to a JdbcSQLErrorCodesResolver
XStreamSerializer
.snapshotFilter
defaults to a SnapshotFilter.allowAll()
instance.batchSize
defaults to an integer of size 100
.dataType
is defaulted to the byte[]
type.EventSchema
defaults to an EventSchema.EventSchema()
call.maxGapOffset
defaults to an integer of size 10000
.lowestGlobalSequence
defaults to a long of size 1
.gapTimeout
defaults to an integer of size 60000
(1 minute).gapCleaningThreshold
defaults to an integer of size 250
.extendedGapCheckEnabled
defaults to true
.createTokenAt
defaults to JdbcEventStorageEngineStatements.createTokenAt(java.sql.Connection, org.axonframework.eventsourcing.eventstore.jdbc.EventSchema, java.time.Instant)
.appendEvents
defaults to JdbcEventStorageEngineStatements.appendEvents(java.sql.Connection, org.axonframework.eventsourcing.eventstore.jdbc.EventSchema, java.lang.Class<?>, java.util.List<? extends org.axonframework.eventhandling.EventMessage<?>>, org.axonframework.serialization.Serializer, org.axonframework.eventsourcing.eventstore.jdbc.statements.TimestampWriter)
.lastSequenceNumberFor
defaults to JdbcEventStorageEngineStatements.lastSequenceNumberFor(java.sql.Connection, org.axonframework.eventsourcing.eventstore.jdbc.EventSchema, java.lang.String)
.createTailToken
defaults to JdbcEventStorageEngineStatements.createTailToken(java.sql.Connection, org.axonframework.eventsourcing.eventstore.jdbc.EventSchema)
.createHeadToken
defaults to JdbcEventStorageEngineStatements.createHeadToken(java.sql.Connection, org.axonframework.eventsourcing.eventstore.jdbc.EventSchema)
.appendSnapshot
defaults to JdbcEventStorageEngineStatements.appendSnapshot(java.sql.Connection, org.axonframework.eventsourcing.eventstore.jdbc.EventSchema, java.lang.Class<?>, org.axonframework.eventhandling.DomainEventMessage<?>, org.axonframework.serialization.Serializer, org.axonframework.eventsourcing.eventstore.jdbc.statements.TimestampWriter)
.deleteSnapshots
defaults to JdbcEventStorageEngineStatements.deleteSnapshots(java.sql.Connection, org.axonframework.eventsourcing.eventstore.jdbc.EventSchema, java.lang.String, long)
.fetchTrackedEvents
defaults to JdbcEventStorageEngineStatements.fetchTrackedEvents(java.sql.Connection, org.axonframework.eventsourcing.eventstore.jdbc.EventSchema, long)
.cleanGaps
defaults to JdbcEventStorageEngineStatements.cleanGaps(java.sql.Connection, org.axonframework.eventsourcing.eventstore.jdbc.EventSchema, java.util.SortedSet<java.lang.Long>)
.readEventDataForAggregate
defaults to JdbcEventStorageEngineStatements.readEventDataForAggregate(java.sql.Connection, org.axonframework.eventsourcing.eventstore.jdbc.EventSchema, java.lang.String, long, int)
.readSnapshotData
defaults to JdbcEventStorageEngineStatements.readSnapshotData(java.sql.Connection, org.axonframework.eventsourcing.eventstore.jdbc.EventSchema, java.lang.String)
.readEventDataWithoutGaps
defaults to JdbcEventStorageEngineStatements.readEventDataWithoutGaps(java.sql.Connection, org.axonframework.eventsourcing.eventstore.jdbc.EventSchema, long, int)
.readEventDataWithGaps
defaults to JdbcEventStorageEngineStatements.readEventDataWithGaps(java.sql.Connection, org.axonframework.eventsourcing.eventstore.jdbc.EventSchema, long, int, java.util.List<java.lang.Long>)
.
The ConnectionProvider
and TransactionManager
are hard requirements and as such should
be provided.
upcasterChain
public JdbcEventStorageEngine.Builder createTokenAt(CreateTokenAtStatementBuilder createTokenAt)
JdbcEventStorageEngine.createTokenAt
. Defaults to JdbcEventStorageEngineStatements.createTokenAt(Connection, EventSchema, Instant)
.public JdbcEventStorageEngine.Builder appendEvents(AppendEventsStatementBuilder appendEvents)
JdbcEventStorageEngine.appendEvents(Connection, List,
Serializer)
en}. Defaults to JdbcEventStorageEngineStatements.appendEvents(Connection, EventSchema,
Class, List, Serializer, TimestampWriter)
.public JdbcEventStorageEngine.Builder lastSequenceNumberFor(LastSequenceNumberForStatementBuilder lastSequenceNumberFor)
JdbcEventStorageEngine.lastSequenceNumberFor(Connection,
String)
. Defaults to JdbcEventStorageEngineStatements.lastSequenceNumberFor(Connection, EventSchema,
String)
public JdbcEventStorageEngine.Builder createTailToken(CreateTailTokenStatementBuilder createTailToken)
JdbcEventStorageEngine.createTailToken(Connection)
. Defaults
to JdbcEventStorageEngineStatements.createTailToken(Connection, EventSchema)
public JdbcEventStorageEngine.Builder createHeadToken(CreateHeadTokenStatementBuilder createHeadToken)
JdbcEventStorageEngine.createHeadToken(Connection)
. Defaults
to JdbcEventStorageEngineStatements.createHeadToken(Connection, EventSchema)
public JdbcEventStorageEngine.Builder appendSnapshot(AppendSnapshotStatementBuilder appendSnapshot)
JdbcEventStorageEngine.appendSnapshot(Connection,
DomainEventMessage, Serializer)
. Defaults to JdbcEventStorageEngineStatements.appendEvents(Connection,
EventSchema, Class, List, Serializer, TimestampWriter)
public JdbcEventStorageEngine.Builder deleteSnapshots(DeleteSnapshotsStatementBuilder deleteSnapshots)
JdbcEventStorageEngine.deleteSnapshots(Connection, String,
long)
. Defaults to JdbcEventStorageEngineStatements.deleteSnapshots(Connection, EventSchema, String,
long)
public JdbcEventStorageEngine.Builder fetchTrackedEvents(FetchTrackedEventsStatementBuilder fetchTrackedEvents)
JdbcEventStorageEngine.fetchTrackedEvents(Connection, long)
.
Defaults to JdbcEventStorageEngineStatements.fetchTrackedEvents(Connection, EventSchema, long)
public JdbcEventStorageEngine.Builder cleanGaps(CleanGapsStatementBuilder cleanGaps)
JdbcEventStorageEngine.cleanGaps(Connection, SortedSet)
.
Defaults to JdbcEventStorageEngineStatements.cleanGaps(Connection, EventSchema, SortedSet)
public JdbcEventStorageEngine.Builder readEventDataForAggregate(ReadEventDataForAggregateStatementBuilder readEventDataForAggregate)
JdbcEventStorageEngine.readEventData(Connection, String, long,
int)
. Defaults to JdbcEventStorageEngineStatements.readEventDataForAggregate(Connection, EventSchema,
String, long, int)
public JdbcEventStorageEngine.Builder readSnapshotData(ReadSnapshotDataStatementBuilder readSnapshotData)
JdbcEventStorageEngine.readSnapshotData(Connection, String)
.
Defaults to JdbcEventStorageEngineStatements.readSnapshotData(Connection, EventSchema, String)
public JdbcEventStorageEngine.Builder readEventDataWithoutGaps(ReadEventDataWithoutGapsStatementBuilder readEventDataWithoutGaps)
JdbcEventStorageEngine.readEventDataWithoutGaps(Connection,
long, int)
. Defaults to JdbcEventStorageEngineStatements.readEventDataWithoutGaps(Connection,
EventSchema, long, int)
public JdbcEventStorageEngine.Builder readEventDataWithGaps(ReadEventDataWithGapsStatementBuilder readEventDataWithGaps)
JdbcEventStorageEngine.readEventDataWithGaps(Connection, long,
int, List)
. Defaults to JdbcEventStorageEngineStatements.readEventDataWithGaps(Connection,
EventSchema, long, int, List)
public JdbcEventStorageEngine.Builder snapshotSerializer(Serializer snapshotSerializer)
AbstractEventStorageEngine.Builder
Serializer
used to serialize and deserialize snapshots. Defaults to a XStreamSerializer
.snapshotSerializer
in class BatchingEventStorageEngine.Builder
snapshotSerializer
- a Serializer
used to serialize and deserialize snapshotspublic JdbcEventStorageEngine.Builder upcasterChain(EventUpcaster upcasterChain)
AbstractEventStorageEngine.Builder
EventUpcaster
used to deserialize events of older revisions. Defaults to a NoOpEventUpcaster
.upcasterChain
in class BatchingEventStorageEngine.Builder
upcasterChain
- an EventUpcaster
used to deserialize events of older revisionspublic JdbcEventStorageEngine.Builder persistenceExceptionResolver(PersistenceExceptionResolver persistenceExceptionResolver)
PersistenceExceptionResolver
used to detect concurrency exceptions from the backing
database. If the persistenceExceptionResolver
is not specified, persistence exceptions are not
explicitly resolved. Defaults to a JdbcSQLErrorCodesResolver
.persistenceExceptionResolver
in class BatchingEventStorageEngine.Builder
persistenceExceptionResolver
- the PersistenceExceptionResolver
used to detect concurrency
exceptions from the backing databasepublic JdbcEventStorageEngine.Builder eventSerializer(Serializer eventSerializer)
AbstractEventStorageEngine.Builder
Serializer
used to serialize and deserialize the Event Message's payload and Meta Data with.
Defaults to a XStreamSerializer
.eventSerializer
in class BatchingEventStorageEngine.Builder
eventSerializer
- The serializer to serialize the Event Message's payload and Meta Data with@Deprecated public JdbcEventStorageEngine.Builder snapshotFilter(Predicate<? super DomainEventData<?>> snapshotFilter)
snapshotFilter(SnapshotFilter)
snapshotFilter
deciding whether to take a snapshot into account. Can be set to filter out
specific snapshot revisions which should not be applied. Defaults to a Predicate
which returns true
regardless.snapshotFilter
in class BatchingEventStorageEngine.Builder
snapshotFilter
- a Predicate
which decides whether to take a snapshot into accountpublic JdbcEventStorageEngine.Builder snapshotFilter(SnapshotFilter snapshotFilter)
AbstractEventStorageEngine.Builder
snapshotFilter
deciding whether to take a snapshot into account. Can be set to filter out
specific snapshot revisions which should not be applied. Defaults to SnapshotFilter.allowAll()
.
Note that SnapshotFilter
instances can be combined and should return true
if they handle a
snapshot they wish to ignore.
snapshotFilter
in class BatchingEventStorageEngine.Builder
snapshotFilter
- a SnapshotFilter
which decides whether to take a snapshot into accountpublic JdbcEventStorageEngine.Builder batchSize(int batchSize)
BatchingEventStorageEngine.Builder
batchSize
specifying the number of events that should be read at each database access. When
more than this number of events must be read to rebuild an aggregate's state, the events are read in batches
of this size. Defaults to an integer of 100
.
Tip: if you use a snapshotter, make sure to choose snapshot trigger and batch size such that a single batch will generally retrieve all events required to rebuild an aggregate's state.
batchSize
in class BatchingEventStorageEngine.Builder
batchSize
- an int
specifying the number of events that should be read at each database accesspublic JdbcEventStorageEngine.Builder connectionProvider(ConnectionProvider connectionProvider)
ConnectionProvider
which provides access to a JDBC connection.connectionProvider
- a ConnectionProvider
which provides access to a JDBC connectionpublic JdbcEventStorageEngine.Builder transactionManager(TransactionManager transactionManager)
TransactionManager
used to manage transactions around fetching event data. Required by
certain databases for reading blob data.transactionManager
- a TransactionManager
used to manage transactions around fetching event
datapublic JdbcEventStorageEngine.Builder dataType(Class<?> dataType)
dataType
specifying the serialized type of the Event Message's payload and Meta Data.
Defaults to the byte[]
Class
.dataType
- a Class
specifying the serialized type of the Event Message's payload and Meta Datapublic JdbcEventStorageEngine.Builder schema(EventSchema schema)
EventSchema
describing the database schema of event entries. Defaults to EventSchema.EventSchema()
.schema
- the EventSchema
describing the database schema of event entriespublic JdbcEventStorageEngine.Builder maxGapOffset(int maxGapOffset)
maxGapOffset
specifying the maximum distance in sequence numbers between a missing event and
the event with the highest known index. If the gap is bigger it is assumed that the missing event will not be
committed to the store anymore. This event storage engine will no longer look for those events the next time
a batch is fetched. Defaults to an integer of 10000
(JdbcEventStorageEngine.DEFAULT_MAX_GAP_OFFSET
.maxGapOffset
- an int
specifying the maximum distance in sequence numbers between a missing
event and the event with the highest known indexpublic JdbcEventStorageEngine.Builder lowestGlobalSequence(long lowestGlobalSequence)
lowestGlobalSequence
specifying the first expected auto generated sequence number. For most
data stores this is 1 unless the table has contained entries before. Defaults to a long
of 1
(JdbcEventStorageEngine.DEFAULT_LOWEST_GLOBAL_SEQUENCE
).lowestGlobalSequence
- a long
specifying the first expected auto generated sequence numberpublic JdbcEventStorageEngine.Builder gapTimeout(int gapTimeout)
60000
(JdbcEventStorageEngine.DEFAULT_GAP_TIMEOUT
), thus 1 minute.gapTimeout
- an int
specifying the amount of time until a 'gap' in a TrackingToken may be
considered timed outpublic JdbcEventStorageEngine.Builder gapCleaningThreshold(int gapCleaningThreshold)
250
(JdbcEventStorageEngine.DEFAULT_GAP_CLEANING_THRESHOLD
).gapCleaningThreshold
- an int
specifying the threshold of number of gaps in a token before an
attempt to clean gaps up is takenpublic JdbcEventStorageEngine.Builder extendedGapCheckEnabled(boolean extendedGapCheckEnabled)
globalSequence
larger
than the configured batch size. These gaps could trick the storage engine into believing there are no more
events to read, while there are still positions ahead.
This check comes at a cost of an extra query when a batch retrieval yields an empty result. This may increase database pressure when processors are at the HEAD of a stream, as each batch retrieval will result in an extra query, if there are no results.
Note that the extra query checks for the smallest globalSequence, higher than the last one seen. This query can be executed using an index, which should be a relatively cheap query for most databases.
Defaults to true
extendedGapCheckEnabled
- whether to enable the "extended gap check". Defaults to true
.public JdbcEventStorageEngine build()
JdbcEventStorageEngine
as specified through this Builder.JdbcEventStorageEngine
as specified through this Builderprotected void validate() throws AxonConfigurationException
validate
in class BatchingEventStorageEngine.Builder
AxonConfigurationException
- if one field is asserted to be incorrect according to the Builder's
specificationsCopyright © 2010–2020. All rights reserved.