Class JdbcSequencedDeadLetterQueue.Builder<E extends EventMessage<?>>
- Type Parameters:
E- The type ofEventMessagemaintained in thedead letterof thisSequencedDeadLetterQueue.
- Enclosing class:
JdbcSequencedDeadLetterQueue<E extends EventMessage<?>>
JdbcSequencedDeadLetterQueue.
The following defaults are set by the builder:
- The
table's schemadefaults to aDeadLetterSchema.defaultSchema(). - The
maximum amount of sequencesdefaults to1024. - The
maximum sequence sizedefaults to1024. - The
page sizedefaults to100. - The
claim durationdefaults to 30 seconds.
The processing group,
ConnectionProvider, and
TransactionManager are hard requirements and should be
provided.
The statementFactory(DeadLetterStatementFactory) and
converter(DeadLetterJdbcConverter) are also hard requirements, but users can choose to either set
both explicitly or rely on the DefaultDeadLetterStatementFactory and
DefaultDeadLetterJdbcConverter constructed through the
generic Serializer and
event Serializer.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Initializes aJdbcSequencedDeadLetterQueueas specified through this Builder.claimDuration(Duration claimDuration) Sets the claim duration, which is the time a dead-letter gets locked when processing and waiting for it to complete.connectionProvider(ConnectionProvider connectionProvider) Sets theConnectionProviderwhich provides access to a JDBC connection.converter(DeadLetterJdbcConverter<E, ? extends JdbcDeadLetter<E>> converter) eventSerializer(Serializer eventSerializer) Sets theSerializerto (de)serialize the events, metadata and diagnostics of theDeadLetterwhen storing it to a database.genericSerializer(Serializer genericSerializer) Sets theSerializerto (de)serialize theTrackingToken(if present) of the event in theDeadLetterwhen storing it to the database.maxSequences(int maxSequences) Sets the maximum number of unique sequences thisSequencedDeadLetterQueuemay contain.maxSequenceSize(int maxSequenceSize) Sets the maximum amount oflettersper unique sequences thisSequencedDeadLetterQueuecan store.pageSize(int pageSize) Modifies the page size used when retrieving a sequence of dead letters.processingGroup(String processingGroup) Sets the processing group, which is used for storing and querying which processing group a dead-letteredEventMessagebelonged to.schema(DeadLetterSchema schema) Sets theDeadLetterSchemaused to constructs the table and indices required by thisSequencedDeadLetterQueue.statementFactory(DeadLetterStatementFactory<E> statementFactory) Sets theDeadLetterStatementFactoryused to construct allPreparedStatementsexecuted by thisSequencedDeadLetterQueue.transactionManager(TransactionManager transactionManager) Sets theTransactionManagerused to manage transaction around fetching dead-letter data.protected voidvalidate()Validate whether the fields contained in this Builder are set accordingly.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
processingGroup
Sets the processing group, which is used for storing and querying which processing group a dead-letteredEventMessagebelonged to.- Parameters:
processingGroup- The processing group of thisSequencedDeadLetterQueue.- Returns:
- The current Builder instance, for fluent interfacing.
-
connectionProvider
public JdbcSequencedDeadLetterQueue.Builder<E> connectionProvider(@Nonnull ConnectionProvider connectionProvider) Sets theConnectionProviderwhich provides access to a JDBC connection.- Parameters:
connectionProvider- aConnectionProviderwhich provides access to a JDBC connection- Returns:
- The current Builder instance, for fluent interfacing.
-
transactionManager
public JdbcSequencedDeadLetterQueue.Builder<E> transactionManager(@Nonnull TransactionManager transactionManager) Sets theTransactionManagerused to manage transaction around fetching dead-letter data.- Parameters:
transactionManager- ATransactionManagerused to manage transaction around fetching dead-letter data.- Returns:
- The current Builder instance, for fluent interfacing.
-
schema
Sets theDeadLetterSchemaused to constructs the table and indices required by thisSequencedDeadLetterQueue.The
schemawill be used to construct theDeadLetterStatementFactorywhen it is not explicitly configured.Defaults to the default
schemaconfiguration.- Parameters:
schema- TheDeadLetterSchemaused to constructs the table and indices required by this dead-letter queue.- Returns:
- The current Builder, for fluent interfacing.
-
statementFactory
public JdbcSequencedDeadLetterQueue.Builder<E> statementFactory(@Nonnull DeadLetterStatementFactory<E> statementFactory) Sets theDeadLetterStatementFactoryused to construct allPreparedStatementsexecuted by thisSequencedDeadLetterQueue.When the
statementFactoryis not explicitly configured, this builder defaults to theDefaultDeadLetterStatementFactory. To construct theDefaultDeadLetterStatementFactory, the configuredschema,generic Serializer, andevent Serializerare used.- Parameters:
statementFactory- TheDeadLetterStatementFactoryused to construct allPreparedStatementsexecuted by thisSequencedDeadLetterQueue.- Returns:
- The current Builder, for fluent interfacing.
-
converter
public JdbcSequencedDeadLetterQueue.Builder<E> converter(@Nonnull DeadLetterJdbcConverter<E, ? extends JdbcDeadLetter<E>> converter) Sets theDeadLetterJdbcConverterused to convert aResultSetinto aJdbcDeadLetterimplementation. Theconverteris, for example, used to service theJdbcSequencedDeadLetterQueue.deadLetters()andJdbcSequencedDeadLetterQueue.deadLetterSequence(Object)operations.When the
converteris not explicitly configured, this builder defaults to theDefaultDeadLetterJdbcConverter. To construct theDefaultDeadLetterJdbcConverter, the configuredgeneric Serializer, andevent Serializerare used.- Parameters:
converter- TheDeadLetterJdbcConverterused to convert aResultSetinto aJdbcDeadLetterimplementation.- Returns:
- The current Builder, for fluent interfacing.
-
genericSerializer
public JdbcSequencedDeadLetterQueue.Builder<E> genericSerializer(@Nonnull Serializer genericSerializer) Sets theSerializerto (de)serialize theTrackingToken(if present) of the event in theDeadLetterwhen storing it to the database.The
genericSerializerwill be used to construct theDeadLetterStatementFactoryand/orDeadLetterJdbcConverterwhen either of them are not explicitly configured.- Parameters:
genericSerializer- The serializer to use.- Returns:
- The current Builder instance, for fluent interfacing.
-
eventSerializer
Sets theSerializerto (de)serialize the events, metadata and diagnostics of theDeadLetterwhen storing it to a database.The
eventSerializerwill be used to construct theDeadLetterStatementFactoryand/orDeadLetterJdbcConverterwhen either of them are not explicitly configured.- Parameters:
eventSerializer- The serializer to use.- Returns:
- The current Builder instance, for fluent interfacing.
-
maxSequences
Sets the maximum number of unique sequences thisSequencedDeadLetterQueuemay contain.The given
maxSequencesis required to be a positive number. The maximum number of unique sequences defaults to1024.- Parameters:
maxSequences- The maximum amount of unique sequences for the queue under construction.- Returns:
- The current Builder, for fluent interfacing.
-
maxSequenceSize
Sets the maximum amount oflettersper unique sequences thisSequencedDeadLetterQueuecan store.The given
maxSequenceSizeis required to be a positive number. The maximum amount of letters per unique sequence defaults to1024.- Parameters:
maxSequenceSize- The maximum amount oflettersper unique sequence.- Returns:
- The current Builder, for fluent interfacing.
-
claimDuration
Sets the claim duration, which is the time a dead-letter gets locked when processing and waiting for it to complete. Other invocations of theJdbcSequencedDeadLetterQueue.process(Predicate, Function)method will be unable to process a sequence while the claim is active. The claim duration defaults to 30 seconds.Claims are automatically released once the item is requeued. Thus, the claim time is a backup policy in case of unforeseen trouble such as database connection issues.
- Parameters:
claimDuration- The longest claim duration allowed.- Returns:
- The current Builder instance, for fluent interfacing.
-
pageSize
Modifies the page size used when retrieving a sequence of dead letters.Used during the
JdbcSequencedDeadLetterQueue.deadLetterSequence(Object)andJdbcSequencedDeadLetterQueue.deadLetters()operations. Defaults to a100.- Parameters:
pageSize- The page size used when retrieving a sequence of dead letters.- Returns:
- The current Builder instance, for fluent interfacing.
-
build
Initializes aJdbcSequencedDeadLetterQueueas specified through this Builder.- Returns:
- A
JdbcSequencedDeadLetterQueueas specified through this Builder.
-
validate
protected void validate()Validate whether the fields contained in this Builder are set accordingly.- Throws:
AxonConfigurationException- When one field asserts to be incorrect according to the Builder's specifications.
-