Class DefaultEventPublicationRegistry
java.lang.Object
org.springframework.modulith.events.core.DefaultEventPublicationRegistry
- All Implemented Interfaces:
DisposableBean
,CompletedEventPublications
,EventPublicationRegistry
public class DefaultEventPublicationRegistry
extends Object
implements DisposableBean, EventPublicationRegistry, CompletedEventPublications
A registry to capture event publications to
ApplicationListener
s. Allows to register those publications, mark
them as completed and lookup incomplete publications.- Author:
- Oliver Drotbohm, Björn Kieling, Dmitry Belyaev
-
Constructor Summary
ConstructorDescriptionDefaultEventPublicationRegistry
(EventPublicationRepository events, Clock clock) Creates a newDefaultEventPublicationRegistry
for the givenEventPublicationRepository
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteCompletedPublicationsOlderThan
(Duration duration) Deletes all completedTargetEventPublication
s that have been completed before the givenDuration
.void
deletePublications
(Predicate<EventPublication> filter) Deletes allEventPublication
s matching the givenPredicate
.void
deletePublicationsOlderThan
(Duration duration) Deletes allEventPublication
s whose completion date is older than the givenDuration
.void
destroy()
Collection<? extends TargetEventPublication>
findAll()
Returns allEventPublication
s that have already been completed.Returns allTargetEventPublication
s that have not been completed yet.findIncompletePublicationsOlderThan
(Duration duration) Returns allTargetEventPublication
s that have not been completed yet and have been published before the given duration in relation to "now".void
markCompleted
(Object event, PublicationTargetIdentifier targetIdentifier) Marks the publication for the given event andPublicationTargetIdentifier
as completed.store
(Object event, Stream<PublicationTargetIdentifier> listeners) StoresTargetEventPublication
s for the given event andApplicationListener
s.
-
Constructor Details
-
DefaultEventPublicationRegistry
Creates a newDefaultEventPublicationRegistry
for the givenEventPublicationRepository
.- Parameters:
events
- must not be null.clock
- must not be null.
-
-
Method Details
-
store
public Collection<TargetEventPublication> store(Object event, Stream<PublicationTargetIdentifier> listeners) Description copied from interface:EventPublicationRegistry
StoresTargetEventPublication
s for the given event andApplicationListener
s.- Specified by:
store
in interfaceEventPublicationRegistry
- Parameters:
event
- must not be null.listeners
- must not be null.
-
findIncompletePublications
Description copied from interface:EventPublicationRegistry
Returns allTargetEventPublication
s that have not been completed yet.- Specified by:
findIncompletePublications
in interfaceEventPublicationRegistry
- Returns:
- will never be null.
-
findIncompletePublicationsOlderThan
Description copied from interface:EventPublicationRegistry
Returns allTargetEventPublication
s that have not been completed yet and have been published before the given duration in relation to "now".- Specified by:
findIncompletePublicationsOlderThan
in interfaceEventPublicationRegistry
- Parameters:
duration
- must not be null.- Returns:
- will never be null.
-
markCompleted
@Transactional(propagation=REQUIRES_NEW) public void markCompleted(Object event, PublicationTargetIdentifier targetIdentifier) Description copied from interface:EventPublicationRegistry
Marks the publication for the given event andPublicationTargetIdentifier
as completed.- Specified by:
markCompleted
in interfaceEventPublicationRegistry
- Parameters:
event
- must not be null.targetIdentifier
- must not be null.
-
deleteCompletedPublicationsOlderThan
Description copied from interface:EventPublicationRegistry
Deletes all completedTargetEventPublication
s that have been completed before the givenDuration
.- Specified by:
deleteCompletedPublicationsOlderThan
in interfaceEventPublicationRegistry
- Parameters:
duration
- must not be null.
-
findAll
Description copied from interface:CompletedEventPublications
Returns allEventPublication
s that have already been completed.- Specified by:
findAll
in interfaceCompletedEventPublications
- Returns:
- will never be null.
-
deletePublications
Description copied from interface:CompletedEventPublications
Deletes allEventPublication
s matching the givenPredicate
. Note that implementations will iterate all completedEventPublication
s and apply the predicate in memory.- Specified by:
deletePublications
in interfaceCompletedEventPublications
- Parameters:
filter
- must not be null.
-
deletePublicationsOlderThan
Description copied from interface:CompletedEventPublications
Deletes allEventPublication
s whose completion date is older than the givenDuration
.- Specified by:
deletePublicationsOlderThan
in interfaceCompletedEventPublications
- Parameters:
duration
- must not be null.
-
destroy
public void destroy()- Specified by:
destroy
in interfaceDisposableBean
-