Class JpaSequencedDeadLetterQueue.Builder<T extends EventMessage<?>>

java.lang.Object
org.axonframework.eventhandling.deadletter.jpa.JpaSequencedDeadLetterQueue.Builder<T>
Type Parameters:
T - The type of Message maintained in this JpaSequencedDeadLetterQueue.
Enclosing class:
JpaSequencedDeadLetterQueue<M extends EventMessage<?>>

public static class JpaSequencedDeadLetterQueue.Builder<T extends EventMessage<?>> extends Object
Builder class to instantiate an 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 Details

    • Builder

      public Builder()
  • Method Details

    • processingGroup

      public JpaSequencedDeadLetterQueue.Builder<T> processingGroup(String 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 this SequencedDeadLetterQueue.
      Returns:
      the current Builder instance, for fluent interfacing
    • maxSequences

      public JpaSequencedDeadLetterQueue.Builder<T> maxSequences(int maxSequences)
      Sets the maximum number of unique sequences this SequencedDeadLetterQueue may contain.

      The given maxSequences is required to be a positive number, higher or equal to 128. It defaults to 1024.

      Parameters:
      maxSequences - The maximum amount of unique sequences for the queue under construction.
      Returns:
      The current Builder, for fluent interfacing.
    • maxSequenceSize

      public JpaSequencedDeadLetterQueue.Builder<T> maxSequenceSize(int maxSequenceSize)
      Sets the maximum amount of letters per unique sequences this SequencedDeadLetterQueue can store.

      The given maxSequenceSize is required to be a positive number, higher or equal to 128. It defaults to 1024.

      Parameters:
      maxSequenceSize - The maximum amount of letters per unique sequence.
      Returns:
      The current Builder, for fluent interfacing.
    • entityManagerProvider

      public JpaSequencedDeadLetterQueue.Builder<T> entityManagerProvider(EntityManagerProvider entityManagerProvider)
      Sets the EntityManagerProvider which provides the EntityManager used to access the underlying database for this JpaSequencedDeadLetterQueue implementation.
      Parameters:
      entityManagerProvider - a EntityManagerProvider which provides the EntityManager used to access the underlying database
      Returns:
      the current Builder instance, for fluent interfacing
    • transactionManager

      public JpaSequencedDeadLetterQueue.Builder<T> transactionManager(TransactionManager transactionManager)
      Sets the TransactionManager used to manage transaction around fetching event data. Required by certain databases for reading blob data.
      Parameters:
      transactionManager - a TransactionManager used to manage transaction around fetching event data
      Returns:
      the current Builder instance, for fluent interfacing
    • serializer

      public JpaSequencedDeadLetterQueue.Builder<T> serializer(Serializer serializer)
      Sets the Serializer to (de)serialize the event payload, event metadata, tracking token, and diagnostics of the DeadLetter when storing it to the database.
      Parameters:
      serializer - The serializer to use
      Returns:
      the current Builder instance, for fluent interfacing
    • eventSerializer

      public JpaSequencedDeadLetterQueue.Builder<T> eventSerializer(Serializer serializer)
      Sets the Serializer to (de)serialize the event payload, event metadata, and diagnostics of the DeadLetter when storing it to the database.
      Parameters:
      serializer - The serializer to use
      Returns:
      the current Builder instance, for fluent interfacing
    • genericSerializer

      public JpaSequencedDeadLetterQueue.Builder<T> genericSerializer(Serializer serializer)
      Sets the Serializer to (de)serialize the tracking token of the event in the DeadLetter when storing it to the database.
      Parameters:
      serializer - The serializer to use
      Returns:
      the current Builder instance, for fluent interfacing
    • clearConverters

      public JpaSequencedDeadLetterQueue.Builder<T> clearConverters()
      Removes all current converters currently configured, including the default EventMessageDeadLetterJpaConverter.
      Returns:
      the current Builder instance, for fluent interfacing
    • addConverter

      Adds a DeadLetterJpaConverter to the configuration, which is used to deserialize dead-letter entries from the database.
      Returns:
      the current Builder instance, for fluent interfacing
    • claimDuration

      public JpaSequencedDeadLetterQueue.Builder<T> claimDuration(Duration claimDuration)
      Sets the claim duration, which is the time a message gets locked when processing and waiting for it to complete. Other invocations of the JpaSequencedDeadLetterQueue.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

      public JpaSequencedDeadLetterQueue.Builder<T> queryPageSize(int queryPageSize)
      Modifies the page size used when retrieving a sequence of dead letters. Defaults to 100 items in a page.
      Parameters:
      queryPageSize - The page size
      Returns:
      the current Builder instance, for fluent interfacing
    • build

      public JpaSequencedDeadLetterQueue<T> build()
      Initializes a JpaSequencedDeadLetterQueue as specified through this Builder.
      Returns:
      A JpaSequencedDeadLetterQueue as 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.