StreamBridge resolveDestination considers binderName in cache hit

This commit is contained in:
Sean Doyle
2022-05-31 10:25:06 -05:00
committed by Oleg Zhurakousky
parent 6dd6774280
commit 862b2003ab

View File

@@ -271,7 +271,12 @@ public final class StreamBridge implements SmartInitializingSingleton {
@SuppressWarnings({ "unchecked"})
synchronized MessageChannel resolveDestination(String destinationName, ProducerProperties producerProperties, String binderName) {
MessageChannel messageChannel = this.channelCache.get(destinationName);
MessageChannel messageChannel = null;
if (StringUtils.hasText(binderName)) {
messageChannel = this.channelCache.get(binderName + " " + destinationName);
} else {
messageChannel = this.channelCache.get(destinationName);
}
if (messageChannel == null) {
if (this.applicationContext.containsBean(destinationName)) {
messageChannel = this.applicationContext.getBean(destinationName, MessageChannel.class);
@@ -299,7 +304,11 @@ public final class StreamBridge implements SmartInitializingSingleton {
this.addInterceptors((AbstractMessageChannel) messageChannel, destinationName);
this.bindingService.bindProducer(messageChannel, destinationName, false, binder);
this.channelCache.put(destinationName, messageChannel);
if (StringUtils.hasText(binderName)) {
this.channelCache.put(binderName + " " + destinationName, messageChannel);
} else {
this.channelCache.put(destinationName, messageChannel);
}
}
}