StreamBridge's dynamic destinations should be closed on shutdown.

- if not, we might lose some messages on shutdown especially in case of kafka async mode producing.

Resolves #2835
This commit is contained in:
kurt
2023-10-20 14:39:33 +09:00
committed by Oleg Zhurakousky
parent eebbe7a5bb
commit 3575c9937d
2 changed files with 28 additions and 1 deletions

View File

@@ -639,6 +639,25 @@ public class StreamBridgeTests {
}
}
@Test
void testDynamicDestinationDestroy() {
BindingService bindingService;
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration
.getCompleteConfiguration(InterceptorConfiguration.class))
.web(WebApplicationType.NONE).run(
"--spring.jmx.enabled=false",
"--spring.cloud.stream.dynamic-destination-cache-size=1"
)) {
StreamBridge bridge = context.getBean(StreamBridge.class);
bridge.send("a", "hello foo");
bindingService = context.getBean(BindingService.class);
assertThat(bindingService.getProducerBindingNames().length).isEqualTo(1);
assertThat(bindingService.getProducerBindingNames()[0]).isEqualTo("a");
}
assertThat(bindingService.getProducerBindingNames().length).isEqualTo(0);
}
@Test
void testWithIntegrationFlowBecauseMarcinSaidSo() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration