From 862b2003abc778dc1627dcfe071bd6180d2ed28d Mon Sep 17 00:00:00 2001 From: Sean Doyle <83722846+waroir20@users.noreply.github.com> Date: Tue, 31 May 2022 10:25:06 -0500 Subject: [PATCH] StreamBridge resolveDestination considers binderName in cache hit --- .../cloud/stream/function/StreamBridge.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java index 8671b79f5..3c8aa2f69 100644 --- a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java +++ b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java @@ -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); + } } }