Class JpaPollingEventCoordinator
java.lang.Object
org.axonframework.eventsourcing.eventstore.jpa.JpaPollingEventCoordinator
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.axonframework.eventsourcing.eventstore.EventCoordinator
EventCoordinator.Handle -
Field Summary
Fields inherited from interface org.axonframework.eventsourcing.eventstore.EventCoordinator
SIMPLE -
Constructor Summary
ConstructorsConstructorDescriptionJpaPollingEventCoordinator(EntityManagerProvider entityManagerProvider, Duration pollingInterval) Creates a new JPA polling event coordinator. -
Method Summary
Modifier and TypeMethodDescriptionstartCoordination(Runnable onAppendDetected) Starts a coordination instance that will invoke the given callback when new events are appended.
-
Constructor Details
-
JpaPollingEventCoordinator
public JpaPollingEventCoordinator(@Nonnull EntityManagerProvider entityManagerProvider, @Nonnull Duration pollingInterval) Creates a new JPA polling event coordinator.- Parameters:
entityManagerProvider- providesEntityManagerinstances for querying the event table; must not benullpollingInterval- the duration between polling cycles; must be positive and notnull- Throws:
NullPointerException- if either argument isnullIllegalArgumentException- ifpollingIntervalis not positive
-
-
Method Details
-
startCoordination
Description copied from interface:EventCoordinatorStarts 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:
startCoordinationin interfaceEventCoordinator- Parameters:
onAppendDetected- the callback to invoke when new events are detected; must not benull- Returns:
- a handle to interact with the coordination instance, including notifying of new events and terminating
the coordination; never
null
-