Unpublished events, sending duplicates on application startup in some cases #926
Labels
in: event publication registry
Event publication registry
meta: waiting for feedback
Waiting for feedback of the original reporter
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)
The text was updated successfully, but these errors were encountered: