Class JpaSequencedDeadLetterQueue.Builder<T extends EventMessage<?>>
- Type Parameters:
T- The type ofMessagemaintained in thisJpaSequencedDeadLetterQueue.
- Enclosing class:
JpaSequencedDeadLetterQueue<M extends EventMessage<?>>
JpaSequencedDeadLetterQueue.
The maximum number of unique sequences defaults to 1024, the maximum amount of dead letters inside a
unique sequence to 1024, the claim duration defaults to 30 seconds, the query page size defaults
to 100, and the converters default to containing a single EventMessageDeadLetterJpaConverter.
If you have custom EventMessage to use with this queue, replace the current (or add a second) converter.
The processingGroup, EntityManagerProvider, TransactionManager and Serializer
have to be configured for the JpaSequencedDeadLetterQueue to be constructed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddConverter(DeadLetterJpaConverter<EventMessage<?>> converter) Adds aDeadLetterJpaConverterto the configuration, which is used to deserialize dead-letter entries from the database.build()Initializes aJpaSequencedDeadLetterQueueas specified through this Builder.claimDuration(Duration claimDuration) Sets the claim duration, which is the time a message gets locked when processing and waiting for it to complete.Removes all current converters currently configured, including the defaultEventMessageDeadLetterJpaConverter.entityManagerProvider(EntityManagerProvider entityManagerProvider) Sets theEntityManagerProviderwhich provides theEntityManagerused to access the underlying database for thisJpaSequencedDeadLetterQueueimplementation.eventSerializer(Serializer serializer) Sets theSerializerto (de)serialize the event payload, event metadata, and diagnostics of theDeadLetterwhen storing it to the database.genericSerializer(Serializer serializer) Sets theSerializerto (de)serialize the tracking token 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.processingGroup(String processingGroup) Sets the processing group, which is used for storing and querying which event processor the deadlettered item belonged to.queryPageSize(int queryPageSize) Modifies the page size used when retrieving a sequence of dead letters.serializer(Serializer serializer) Sets theSerializerto deserialize the events, metadata and diagnostics of theDeadLetterwhen storing it to a database.transactionManager(TransactionManager transactionManager) Sets theTransactionManagerused to manage transaction around fetching event 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 event processor the deadlettered item belonged to.- Parameters:
processingGroup- The processing group of thisSequencedDeadLetterQueue.- 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, higher or equal to128. It 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, higher or equal to128. It defaults to1024.- Parameters:
maxSequenceSize- The maximum amount oflettersper unique sequence.- Returns:
- The current Builder, for fluent interfacing.
-
entityManagerProvider
public JpaSequencedDeadLetterQueue.Builder<T> entityManagerProvider(EntityManagerProvider entityManagerProvider) Sets theEntityManagerProviderwhich provides theEntityManagerused to access the underlying database for thisJpaSequencedDeadLetterQueueimplementation.- Parameters:
entityManagerProvider- aEntityManagerProviderwhich provides theEntityManagerused to access the underlying database- Returns:
- the current Builder instance, for fluent interfacing
-
transactionManager
public JpaSequencedDeadLetterQueue.Builder<T> transactionManager(TransactionManager transactionManager) Sets theTransactionManagerused to manage transaction around fetching event data. Required by certain databases for reading blob data.- Parameters:
transactionManager- aTransactionManagerused to manage transaction around fetching event data- Returns:
- the current Builder instance, for fluent interfacing
-
serializer
Sets theSerializerto deserialize the events, metadata and diagnostics of theDeadLetterwhen storing it to a database.- Parameters:
serializer- The serializer to use- Returns:
- the current Builder instance, for fluent interfacing
-
eventSerializer
Sets theSerializerto (de)serialize the event payload, event metadata, and diagnostics of theDeadLetterwhen storing it to the database.- Parameters:
serializer- The serializer to use- Returns:
- the current Builder instance, for fluent interfacing
-
genericSerializer
Sets theSerializerto (de)serialize the tracking token of the event in theDeadLetterwhen storing it to the database.- Parameters:
serializer- The serializer to use- Returns:
- the current Builder instance, for fluent interfacing
-
clearConverters
Removes all current converters currently configured, including the defaultEventMessageDeadLetterJpaConverter.- Returns:
- the current Builder instance, for fluent interfacing
-
addConverter
public JpaSequencedDeadLetterQueue.Builder<T> addConverter(DeadLetterJpaConverter<EventMessage<?>> converter) Adds aDeadLetterJpaConverterto the configuration, which is used to deserialize dead-letter entries from the database.- Returns:
- the current Builder instance, for fluent interfacing
-
claimDuration
Sets the claim duration, which is the time a message gets locked when processing and waiting for it to complete. Other invocations of theJpaSequencedDeadLetterQueue.process(Predicate, Function)method will be unable to process a sequence while the claim is active. Its default is 30 seconds.Claims are automatically released once the item is requeued, the claim time is a backup policy in case of unforeseen trouble such as down database connections.
- Parameters:
claimDuration- The longest claim duration allowed.- Returns:
- the current Builder instance, for fluent interfacing
-
queryPageSize
Modifies the page size used when retrieving a sequence of dead letters. Defaults to100items in a page.- Parameters:
queryPageSize- The page size- Returns:
- the current Builder instance, for fluent interfacing
-
build
Initializes aJpaSequencedDeadLetterQueueas specified through this Builder.- Returns:
- A
JpaSequencedDeadLetterQueueas 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.
-