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 Predicate
which returns true
regardless.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
.
The ConnectionProvider
and TransactionManager
are hard requirements and as such should
be provided.
upcasterChain
Modifier and Type | Method and Description |
---|---|
JdbcEventStorageEngine.Builder |
batchSize(int batchSize)
Sets the
batchSize specifying the number of events that should be read at each database access. |
JdbcEventStorageEngine |
build()
Initializes a
JdbcEventStorageEngine as specified through this Builder. |
JdbcEventStorageEngine.Builder |
connectionProvider(ConnectionProvider connectionProvider)
Sets the
ConnectionProvider which provides access to a JDBC connection. |
JdbcEventStorageEngine.Builder |
dataType(Class<?> dataType)
Sets the
dataType specifying the serialized type of the Event Message's payload and Meta Data. |
JdbcEventStorageEngine.Builder |
eventSerializer(Serializer eventSerializer)
Sets the
Serializer used to serialize and deserialize the Event Message's payload and Meta Data with. |
JdbcEventStorageEngine.Builder |
extendedGapCheckEnabled(boolean extendedGapCheckEnabled)
Indicates whether an extra query should be performed to verify for gaps in the
globalSequence larger
than the configured batch size. |
JdbcEventStorageEngine.Builder |
gapCleaningThreshold(int gapCleaningThreshold)
Sets the threshold of number of gaps in a token before an attempt to clean gaps up is taken.
|
JdbcEventStorageEngine.Builder |
gapTimeout(int gapTimeout)
Sets the amount of time until a 'gap' in a TrackingToken may be considered timed out.
|
JdbcEventStorageEngine.Builder |
lowestGlobalSequence(long lowestGlobalSequence)
Sets the
lowestGlobalSequence specifying the first expected auto generated sequence number. |
JdbcEventStorageEngine.Builder |
maxGapOffset(int maxGapOffset)
Sets the
maxGapOffset specifying the maximum distance in sequence numbers between a missing event and
the event with the highest known index. |
JdbcEventStorageEngine.Builder |
persistenceExceptionResolver(PersistenceExceptionResolver persistenceExceptionResolver)
Sets the
PersistenceExceptionResolver used to detect concurrency exceptions from the backing
database. |
JdbcEventStorageEngine.Builder |
schema(EventSchema schema)
Sets the
EventSchema describing the database schema of event entries. |
JdbcEventStorageEngine.Builder |
snapshotFilter(Predicate<? super DomainEventData<?>> snapshotFilter)
Sets the
snapshotFilter deciding whether to take a snapshot into account. |
JdbcEventStorageEngine.Builder |
snapshotSerializer(Serializer snapshotSerializer)
Sets the
Serializer used to serialize and deserialize snapshots. |
JdbcEventStorageEngine.Builder |
transactionManager(TransactionManager transactionManager)
Sets the
TransactionManager used to manage transactions around fetching event data. |
JdbcEventStorageEngine.Builder |
upcasterChain(EventUpcaster upcasterChain)
Sets the
EventUpcaster used to deserialize events of older revisions. |
protected void |
validate()
Validates whether the fields contained in this Builder are set accordingly.
|
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 withpublic JdbcEventStorageEngine.Builder snapshotFilter(Predicate<? super DomainEventData<?>> 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 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 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–2019. All rights reserved.