Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,25 @@ void dynamicDestinationWithBinderNameDestroyForCacheSize() {
}
}

@Test
void bindingsWithBinderNameAreRemovedWithCache() {
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",
"--spring.cloud.stream.binders.kafka1.type=kafka"
)) {
StreamBridge bridge = context.getBean(StreamBridge.class);
bridge.send("binding1", "kafka1", "hello");
bridge.send("binding2", "kafka1", "hello");
bridge.send("binding3", "kafka1", "hello");

BindingServiceProperties bindingServiceProp = context.getBean(BindingServiceProperties.class);
assertThat(bindingServiceProp.getBindings()).containsOnlyKeys("binding3");
}
}

@Test
void withIntegrationFlowBecauseMarcinSaidSo() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,11 @@ protected boolean removeEldestEntry(Map.Entry<String, MessageChannel> eldest) {
if (logger.isDebugEnabled()) {
logger.debug("Removing message channel from cache " + eldest.getKey());
}
if (!configuredBindingNames.contains(eldest.getKey())) {
bindingServiceProperties.getBindings().remove(eldest.getKey());
// The cache key is prefixed with the binder name when one is used, while the
// binding properties are keyed by the binding name the channel was created for.
String bindingName = ((AbstractMessageChannel) eldest.getValue()).getComponentName();
if (!configuredBindingNames.contains(bindingName)) {
bindingServiceProperties.getBindings().remove(bindingName);
}
bindingService.unbindProducers(eldest.getKey());
}
Expand Down
Loading