From 74dda2cdae59ad492748fcfcafcf7a42ce2a64a9 Mon Sep 17 00:00:00 2001 From: Benjamin Knauer Date: Fri, 10 Nov 2023 18:42:06 +0100 Subject: [PATCH] =?UTF-8?q?GH-368=20-=20Consider=20filter=20handed=20into?= =?UTF-8?q?=20IncompleteEventPublications.resubmitIncompletePublications(?= =?UTF-8?q?=E2=80=A6).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original pull request: GH-367. --- .../support/PersistentApplicationEventMulticaster.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spring-modulith-events/spring-modulith-events-core/src/main/java/org/springframework/modulith/events/support/PersistentApplicationEventMulticaster.java b/spring-modulith-events/spring-modulith-events-core/src/main/java/org/springframework/modulith/events/support/PersistentApplicationEventMulticaster.java index 020c4610..cfa29e41 100644 --- a/spring-modulith-events/spring-modulith-events-core/src/main/java/org/springframework/modulith/events/support/PersistentApplicationEventMulticaster.java +++ b/spring-modulith-events/spring-modulith-events-core/src/main/java/org/springframework/modulith/events/support/PersistentApplicationEventMulticaster.java @@ -150,7 +150,7 @@ public class PersistentApplicationEventMulticaster extends AbstractApplicationEv */ @Override public void resubmitIncompletePublications(Predicate filter) { - doResubmitUncompletedPublicationsOlderThan(null); + doResubmitUncompletedPublicationsOlderThan(null, filter); } /* @@ -159,7 +159,7 @@ public class PersistentApplicationEventMulticaster extends AbstractApplicationEv */ @Override public void resubmitIncompletePublicationsOlderThan(Duration duration) { - doResubmitUncompletedPublicationsOlderThan(duration); + doResubmitUncompletedPublicationsOlderThan(duration, __ -> true); } /* @@ -192,7 +192,7 @@ public class PersistentApplicationEventMulticaster extends AbstractApplicationEv }); } - private void doResubmitUncompletedPublicationsOlderThan(@Nullable Duration duration) { + private void doResubmitUncompletedPublicationsOlderThan(@Nullable Duration duration, Predicate filter) { var message = duration != null ? "" : " older than %s".formatted(duration); var registry = this.registry.get(); @@ -205,7 +205,9 @@ public class PersistentApplicationEventMulticaster extends AbstractApplicationEv LOGGER.debug(getConfirmationMessage(publications) + " found."); - publications.forEach(this::invokeTargetListener); + publications.stream() // + .filter(filter) // + .forEach(this::invokeTargetListener); } private static ApplicationListener executeListenerWithCompletion(EventPublication publication,