Class JpaPollingEventCoordinator

java.lang.Object
org.axonframework.eventsourcing.eventstore.jpa.JpaPollingEventCoordinator
All Implemented Interfaces:
EventCoordinator

@Internal public class JpaPollingEventCoordinator extends Object implements EventCoordinator
An EventCoordinator implementation that polls a JPA-managed event table to detect newly appended events.

This coordinator periodically counts all entries in the event table. If the total number of events changes since the last poll, it triggers the provided callback.

  • Constructor Details

    • JpaPollingEventCoordinator

      public JpaPollingEventCoordinator(@Nonnull EntityManagerProvider entityManagerProvider, @Nonnull Duration pollingInterval)
      Creates a new JPA polling event coordinator.
      Parameters:
      entityManagerProvider - provides EntityManager instances for querying the event table; must not be null
      pollingInterval - the duration between polling cycles; must be positive and not null
      Throws:
      NullPointerException - if either argument is null
      IllegalArgumentException - if pollingInterval is not positive
  • Method Details

    • startCoordination

      public EventCoordinator.Handle startCoordination(Runnable onAppendDetected)
      Description copied from interface: EventCoordinator
      Starts a coordination instance that will invoke the given callback when new events are appended.

      The callback may be invoked on an arbitrary thread. Implementations should ensure the callback does not perform long-running or blocking operations. If the callback throws an exception, the coordination is terminated.

      Specified by:
      startCoordination in interface EventCoordinator
      Parameters:
      onAppendDetected - the callback to invoke when new events are detected; must not be null
      Returns:
      a handle to interact with the coordination instance, including notifying of new events and terminating the coordination; never null