Class JpaTokenStore.Builder

java.lang.Object
org.axonframework.eventhandling.tokenstore.jpa.JpaTokenStore.Builder
Enclosing class:
JpaTokenStore

public static class JpaTokenStore.Builder extends Object
Builder class to instantiate a JpaTokenStore.

The claimTimeout to a 10 seconds duration, and nodeId is defaulted to the name of the managed bean for the runtime system of the Java virtual machine. The EntityManagerProvider and Serializer are a hard requirements and as such should be provided.

  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • entityManagerProvider

      public JpaTokenStore.Builder entityManagerProvider(EntityManagerProvider entityManagerProvider)
      Sets the EntityManagerProvider which provides the EntityManager used to access the underlying database.
      Parameters:
      entityManagerProvider - a EntityManagerProvider which provides the EntityManager used to access the underlying database
      Returns:
      the current Builder instance, for fluent interfacing
    • serializer

      public JpaTokenStore.Builder serializer(Serializer serializer)
      Sets the Serializer used to de-/serialize TrackingTokens with.
      Parameters:
      serializer - a Serializer used to de-/serialize TrackingTokens with
      Returns:
      the current Builder instance, for fluent interfacing
    • claimTimeout

      public JpaTokenStore.Builder claimTimeout(TemporalAmount claimTimeout)
      Sets the claimTimeout specifying the amount of time this process will wait after which this process will force a claim of a TrackingToken. Thus if a claim has not been updated for the given claimTimeout, this process will 'steal' the claim. Defaults to a duration of 10 seconds.
      Parameters:
      claimTimeout - a timeout specifying the time after which this process will force a claim
      Returns:
      the current Builder instance, for fluent interfacing
    • nodeId

      public JpaTokenStore.Builder nodeId(String nodeId)
      Sets the nodeId to identify ownership of the tokens. Defaults to the name of the managed bean for the runtime system of the Java virtual machine
      Parameters:
      nodeId - the id as a String to identify ownership of the tokens
      Returns:
      the current Builder instance, for fluent interfacing
    • loadingLockMode

      public JpaTokenStore.Builder loadingLockMode(jakarta.persistence.LockModeType loadingLockMode)
      The LockModeType to use when loading tokens from the underlying database. Defaults to LockModeType.PESSIMISTIC_WRITE, to force a write lock, which prevents lock upgrading and potential resulting deadlocks.
      Parameters:
      loadingLockMode - The lock mode to use when retrieving tokens from the underlying store
      Returns:
      the current Builder instance, for fluent interfacing
    • build

      public JpaTokenStore build()
      Initializes a JpaTokenStore as specified through this Builder.
      Returns:
      a JpaTokenStore as specified through this Builder
    • validate

      protected void validate() throws AxonConfigurationException
      Validates whether the fields contained in this Builder are set accordingly.
      Throws:
      AxonConfigurationException - if one field is asserted to be incorrect according to the Builder's specifications