spring-projects / spring-projects/spring-modulith
Unpublished events, sending duplicates on application startup in some cases
@odrotbohm is already working on this.
Since Dec 16, 2024.
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 222
- PR merge metrics
- No merged PRs in 30d
Description
when spring.modulith.events.republish-outstanding-events-on-restart=true
and a bean, using this scheduler (code below) to republish incomplete events exists at the same time. it will produce two duplicate events (duplicate the data atleast) of the unpublished/incomplete events from EVENT_PUBLICATION on application startup.
@Scheduled(fixedDelayString = "${events.resubmitFrequencyInSecs}", timeUnit = TimeUnit.SECONDS)
void resubmitUnpublishedEvents() {
incompleteEventPublications.resubmitIncompletePublicationsOlderThan(
eventsConfigProperties.getResubmitOlderThan());
}
Tested with externalized events to an azure eventhub (using kafka apis).
But also on a local kafka container.
in fact, when calling incompleteEventPublications.resubmitIncompletePublications(eventPublication -> true);
from a test using @ApplicationModuleTest, it will produce 3 similar events pr unpublished event. (1 for resubmit on startup, 1 from the scheduled bean, and 1 for the test)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.