GH-125 - More detailed logging of pending event publication lookup on startup.

This commit is contained in:
Oliver Drotbohm
2023-01-26 09:30:50 +01:00
parent 3c25958edc
commit ff8df678e7
3 changed files with 11 additions and 5 deletions

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.modulith.events;
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
@@ -68,7 +69,7 @@ public class DefaultEventPublicationRegistry implements DisposableBean, EventPub
* @see org.springframework.modulith.events.EventPublicationRegistry#findIncompletePublications()
*/
@Override
public Iterable<EventPublication> findIncompletePublications() {
public Collection<EventPublication> findIncompletePublications() {
return events.findIncompletePublications();
}

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.modulith.events;
import java.util.Collection;
import java.util.stream.Stream;
import org.springframework.context.ApplicationListener;
@@ -42,7 +43,7 @@ public interface EventPublicationRegistry {
*
* @return will never be {@literal null}.
*/
Iterable<EventPublication> findIncompletePublications();
Collection<EventPublication> findIncompletePublications();
/**
* Marks the publication for the given event and {@link PublicationTargetIdentifier} as completed.

View File

@@ -113,9 +113,13 @@ public class PersistentApplicationEventMulticaster extends AbstractApplicationEv
@Override
public void afterSingletonsInstantiated() {
for (EventPublication publication : registry.get().findIncompletePublications()) {
invokeTargetListener(publication);
}
LOGGER.debug("Looking up previously pending event publications…");
var publications = registry.get().findIncompletePublications();
LOGGER.debug("{} found.", publications.isEmpty() ? "None" : publications.size());
publications.forEach(this::invokeTargetListener);
}
private void invokeTargetListener(EventPublication publication) {