Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompletedEventPublications.deletePublications(…) deletes incomplete publications #491

Closed
AnthonySlabinck opened this issue Feb 7, 2024 · 2 comments
Assignees
Labels
in: event publication registry Event publication registry type: bug Something isn't working
Milestone

Comments

@AnthonySlabinck
Copy link

AnthonySlabinck commented Feb 7, 2024

The Javadoc says that the CompletedEventPublications interface allows accessing all completed event publications, but actually underlying it calls the EventPublicationRegistry#findIncompletePublications.

This generates following query:

Hibernate: select jep1_0.id,jep1_0.completion_date,jep1_0.event_type,jep1_0.listener_id,jep1_0.publication_date,jep1_0.serialized_event from event_publication jep1_0 where jep1_0.completion_date is null order by jep1_0.publication_date

My code:

import java.time.Duration;
import lombok.RequiredArgsConstructor;
import org.springframework.modulith.events.CompletedEventPublications;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
public class OutboxService {

    private final CompletedEventPublications completedEventPublications;

    @Transactional
    void deleteCompletedPublications() {
        completedEventPublications.deletePublicationsOlderThan(Duration.ofMinutes(30));
    }

}

I hope the provided information is enough.
Kind regards.

@lukasdo
Copy link
Contributor

lukasdo commented Feb 7, 2024

@AnthonySlabinck as you already mentioned the CompletedEventPublications implementation called the wrong method of the EventPublicationRepository. I crafted a PR to address this issue, so that the JavaDoc and official modulith documentation aligns with the code.

@odrotbohm If desired I could add a test to ensure the correct behaviour of the DefaultEventPublicationRegistry in the future.

@odrotbohm
Copy link
Member

I've added comments on GH-491.

@odrotbohm odrotbohm self-assigned this Feb 7, 2024
@odrotbohm odrotbohm added in: event publication registry Event publication registry type: bug Something isn't working labels Feb 7, 2024
@odrotbohm odrotbohm added this to the 1.2 M2 milestone Feb 7, 2024
lukasdo added a commit to lukasdo/spring-modulith that referenced this issue Feb 7, 2024
odrotbohm added a commit that referenced this issue Feb 9, 2024
@odrotbohm odrotbohm changed the title CompletedEventPublications#deletePublications calls findIncompletePublications CompletedEventPublications.deletePublications(…) deletes incomplete publications Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: event publication registry Event publication registry type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants