GH-823 - Move spring.modulith.republish-outstanding-events-on-restart into spring.modulith.events namespace.
This commit is contained in:
@@ -19,6 +19,7 @@ import java.lang.reflect.Method;
|
||||
import java.time.Duration;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
@@ -68,7 +69,8 @@ public class PersistentApplicationEventMulticaster extends AbstractApplicationEv
|
||||
private static final Method SHOULD_HANDLE = ReflectionUtils.findMethod(ApplicationListenerMethodAdapter.class,
|
||||
"shouldHandle", ApplicationEvent.class);
|
||||
|
||||
static final String REPUBLISH_ON_RESTART = "spring.modulith.republish-outstanding-events-on-restart";
|
||||
static final String REPUBLISH_ON_RESTART = "spring.modulith.events.republish-outstanding-events-on-restart";
|
||||
static final String REPUBLISH_ON_RESTART_LEGACY = "spring.modulith.republish-outstanding-events-on-restart";
|
||||
|
||||
private final @NonNull Supplier<EventPublicationRegistry> registry;
|
||||
private final @NonNull Supplier<Environment> environment;
|
||||
@@ -169,7 +171,12 @@ public class PersistentApplicationEventMulticaster extends AbstractApplicationEv
|
||||
@Override
|
||||
public void afterSingletonsInstantiated() {
|
||||
|
||||
if (!Boolean.TRUE.equals(environment.get().getProperty(REPUBLISH_ON_RESTART, Boolean.class))) {
|
||||
var env = environment.get();
|
||||
|
||||
Boolean republishOnRestart = Optional.ofNullable(env.getProperty(REPUBLISH_ON_RESTART, Boolean.class))
|
||||
.orElseGet(() -> env.getProperty(REPUBLISH_ON_RESTART_LEGACY, Boolean.class));
|
||||
|
||||
if (!Boolean.TRUE.equals(republishOnRestart)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,12 @@
|
||||
"name": "spring.modulith.republish-outstanding-events-on-restart",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Whether to republish outstanding event publications on restarts of the application.",
|
||||
"defaultValue": "false"
|
||||
"defaultValue": "false",
|
||||
"deprecation": {
|
||||
"replacement": "spring.modulith.events.republish-outstanding-events-on-restart",
|
||||
"reason": "Moved to spring.modulit.events namespace. To be removed in 1.4.",
|
||||
"since" : "1.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spring.modulith.events.externalization.enabled",
|
||||
@@ -23,6 +28,12 @@
|
||||
"type": "org.springframework.modulith.events.support.CompletionMode",
|
||||
"description": "How to complete event publications.",
|
||||
"defaultValue": "update"
|
||||
},
|
||||
{
|
||||
"name": "spring.modulith.events.republish-outstanding-events-on-restart",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Whether to republish outstanding event publications on restarts of the application.",
|
||||
"defaultValue": "false"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -76,6 +76,18 @@ class PersistentApplicationEventMulticasterUnitTests {
|
||||
verify(registry).processIncompletePublications(any(), any(), any());
|
||||
}
|
||||
|
||||
@Test // GH-240, GH-251, GH-823
|
||||
void triggersRepublicationIfLegacyConfigExplicitlyEnabled() {
|
||||
|
||||
var source = new MapPropertySource("test",
|
||||
Map.of(PersistentApplicationEventMulticaster.REPUBLISH_ON_RESTART_LEGACY, "true"));
|
||||
environment.getPropertySources().addFirst(source);
|
||||
|
||||
multicaster.afterSingletonsInstantiated();
|
||||
|
||||
verify(registry).processIncompletePublications(any(), any(), any());
|
||||
}
|
||||
|
||||
@Test // GH-277
|
||||
void honorsListenerCondition() throws Exception {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user