Class JpaEventPublicationRepository
java.lang.Object
org.springframework.modulith.events.jpa.JpaEventPublicationRepository
- All Implemented Interfaces:
EventPublicationRepository
@Transactional
@Repository
class JpaEventPublicationRepository
extends Object
implements EventPublicationRepository
Repository to store
TargetEventPublications.- Author:
- Oliver Drotbohm, Dmitry Belyaev, Björn Kieling, Cora Iberkleid
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.modulith.events.core.EventPublicationRepository
EventPublicationRepository.FailedCriteria -
Constructor Summary
ConstructorsConstructorDescriptionJpaEventPublicationRepository(jakarta.persistence.EntityManager entityManager, EventSerializer serializer, CompletionMode completionMode) -
Method Summary
Modifier and TypeMethodDescriptionintcountByStatus(EventPublication.Status status) Returns the number ofEventPublications for the given status.create(TargetEventPublication publication) Persists the givenTargetEventPublication.voidDeletes all publications that were already marked as completed.voiddeleteCompletedPublicationsBefore(Instant instant) Deletes all publication that were already marked as completed with a completion date before the given one.voiddeletePublications(List<UUID> identifiers) Deletes all publications with the given identifiers.findByStatus(EventPublication.Status status) Returns allTargetEventPublications with the givenEventPublication.Status.Returns all completed event publications currently found in the system.Returns allTargetEventPublications that have not been completed yet.findIncompletePublicationsByEventAndTargetIdentifier(Object event, PublicationTargetIdentifier targetIdentifier) Return the incompleteTargetEventPublicationfor the given serialized event and listener identifier.Returns allTargetEventPublications that have not been completed and were published before the givenInstant.Class<? extends JpaEventPublication>Returns the type representing completed event publications.voidmarkCompleted(Object event, PublicationTargetIdentifier identifier, Instant completionDate) Marks the publication for the given event andPublicationTargetIdentifierto be completed at the givenInstant.voidmarkCompleted(UUID identifier, Instant completionDate) Marks the publication with the given identifier completed at the givenInstant.voidmarkFailed(UUID identifier) Marks theEventPublicationwith the given identifier as failed.voidmarkProcessing(UUID identifier) Marks theEventPublicationwith the given identifier as processing.booleanmarkResubmitted(UUID identifier, Instant resubmissionDate) Marks theEventPublicationwith the given identifier as resubmitted.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.modulith.events.core.EventPublicationRepository
markCompleted
-
Constructor Details
-
JpaEventPublicationRepository
public JpaEventPublicationRepository(jakarta.persistence.EntityManager entityManager, EventSerializer serializer, CompletionMode completionMode) - Parameters:
entityManager- must not be null.serializer- must not be null.
-
-
Method Details
-
create
Description copied from interface:EventPublicationRepositoryPersists the givenTargetEventPublication.- Specified by:
createin interfaceEventPublicationRepository- Parameters:
publication- must not be null.- Returns:
- will never be null.
-
markProcessing
Description copied from interface:EventPublicationRepositoryMarks theEventPublicationwith the given identifier as processing.- Specified by:
markProcessingin interfaceEventPublicationRepository- Parameters:
identifier- must not be null.- See Also:
-
markCompleted
public void markCompleted(Object event, PublicationTargetIdentifier identifier, Instant completionDate) Description copied from interface:EventPublicationRepositoryMarks the publication for the given event andPublicationTargetIdentifierto be completed at the givenInstant.- Specified by:
markCompletedin interfaceEventPublicationRepository- Parameters:
event- must not be null.identifier- must not be null.completionDate- must not be null.- See Also:
-
markCompleted
Description copied from interface:EventPublicationRepositoryMarks the publication with the given identifier completed at the givenInstant.- Specified by:
markCompletedin interfaceEventPublicationRepository- Parameters:
identifier- must not be null.completionDate- must not be null.- See Also:
-
markFailed
Description copied from interface:EventPublicationRepositoryMarks theEventPublicationwith the given identifier as failed.- Specified by:
markFailedin interfaceEventPublicationRepository- Parameters:
identifier- must not be null.- See Also:
-
markResubmitted
Description copied from interface:EventPublicationRepositoryMarks theEventPublicationwith the given identifier as resubmitted. Returns false in case the update was not successful, which usually means that the instance identified might have been claimed for re-submission by another application instance.- Specified by:
markResubmittedin interfaceEventPublicationRepository- Parameters:
identifier- must not be null.resubmissionDate- must not be null.- Returns:
- whether the
EventPublicationwith the given identifier was marked as resubmitted. - See Also:
-
findIncompletePublications
Description copied from interface:EventPublicationRepositoryReturns allTargetEventPublications that have not been completed yet.- Specified by:
findIncompletePublicationsin interfaceEventPublicationRepository- Returns:
- will never be null.
-
findIncompletePublicationsPublishedBefore
@Transactional(readOnly=true) public List<TargetEventPublication> findIncompletePublicationsPublishedBefore(Instant instant) Description copied from interface:EventPublicationRepositoryReturns allTargetEventPublications that have not been completed and were published before the givenInstant.- Specified by:
findIncompletePublicationsPublishedBeforein interfaceEventPublicationRepository- Parameters:
instant- must not be null.- Returns:
- will never be null.
-
findIncompletePublicationsByEventAndTargetIdentifier
@Transactional(readOnly=true) public Optional<TargetEventPublication> findIncompletePublicationsByEventAndTargetIdentifier(Object event, PublicationTargetIdentifier targetIdentifier) Description copied from interface:EventPublicationRepositoryReturn the incompleteTargetEventPublicationfor the given serialized event and listener identifier.- Specified by:
findIncompletePublicationsByEventAndTargetIdentifierin interfaceEventPublicationRepository- Parameters:
event- must not be null.targetIdentifier- must not be null.- Returns:
- will never be null.
-
findCompletedPublications
Description copied from interface:EventPublicationRepositoryReturns all completed event publications currently found in the system.- Specified by:
findCompletedPublicationsin interfaceEventPublicationRepository- Returns:
- will never be null.
-
findFailedPublications
public List<TargetEventPublication> findFailedPublications(EventPublicationRepository.FailedCriteria criteria) - Specified by:
findFailedPublicationsin interfaceEventPublicationRepository- Parameters:
criteria- must not be null.- Returns:
- will never be null.
-
deletePublications
Description copied from interface:EventPublicationRepositoryDeletes all publications with the given identifiers.- Specified by:
deletePublicationsin interfaceEventPublicationRepository- Parameters:
identifiers- must not be null.
-
deleteCompletedPublications
public void deleteCompletedPublications()Description copied from interface:EventPublicationRepositoryDeletes all publications that were already marked as completed.- Specified by:
deleteCompletedPublicationsin interfaceEventPublicationRepository
-
deleteCompletedPublicationsBefore
Description copied from interface:EventPublicationRepositoryDeletes all publication that were already marked as completed with a completion date before the given one.- Specified by:
deleteCompletedPublicationsBeforein interfaceEventPublicationRepository- Parameters:
instant- must not be null.
-
findByStatus
Description copied from interface:EventPublicationRepositoryReturns allTargetEventPublications with the givenEventPublication.Status.- Specified by:
findByStatusin interfaceEventPublicationRepository- Parameters:
status- must not be null.- Returns:
- will never be null.
-
countByStatus
Description copied from interface:EventPublicationRepositoryReturns the number ofEventPublications for the given status.- Specified by:
countByStatusin interfaceEventPublicationRepository- Parameters:
status- must not be null.- Returns:
- must not be negative
-
getCompletedEntityType
Returns the type representing completed event publications.- Returns:
- will never be null.
- Since:
- 1.3
-