StreamBridge binder name related changes
An internal helper method used by StreamBridge for resolving the binder target type to attach the target binder protocol, does not take into account the binder name when resolving the binder configuration. Fixing this issue. Resolves https://github.com/spring-cloud/spring-cloud-stream/issues/2379 Resolves #2401
This commit is contained in:
committed by
Oleg Zhurakousky
parent
19b867cbf5
commit
8ab9e37c9a
@@ -218,7 +218,8 @@ public final class StreamBridge implements SmartInitializingSingleton {
|
||||
functionToInvoke = new PartitionAwareFunctionWrapper(functionToInvoke, this.applicationContext, producerProperties);
|
||||
}
|
||||
|
||||
String targetType = this.resolveBinderTargetType(bindingName, MessageChannel.class, this.applicationContext.getBean(BinderFactory.class));
|
||||
String targetType = this.resolveBinderTargetType(bindingName, binderName, MessageChannel.class,
|
||||
this.applicationContext.getBean(BinderFactory.class));
|
||||
|
||||
Message<?> messageToSend = data instanceof Message
|
||||
? MessageBuilder.fromMessage((Message) data).setHeaderIfAbsent(MessageUtils.TARGET_PROTOCOL, targetType).build()
|
||||
@@ -299,10 +300,10 @@ public final class StreamBridge implements SmartInitializingSingleton {
|
||||
return messageChannel;
|
||||
}
|
||||
|
||||
private String resolveBinderTargetType(String channelName, Class<?> bindableType, BinderFactory binderFactory) {
|
||||
String binderConfigurationName = this.bindingServiceProperties
|
||||
private String resolveBinderTargetType(String channelName, String binderName, Class<?> bindableType, BinderFactory binderFactory) {
|
||||
String binderConfigurationName = binderName != null ? binderName : this.bindingServiceProperties
|
||||
.getBinder(channelName);
|
||||
Binder binder = binderFactory.getBinder(binderConfigurationName, bindableType);
|
||||
Binder<?, ?, ?> binder = binderFactory.getBinder(binderConfigurationName, bindableType);
|
||||
String targetProtocol = binder.getClass().getSimpleName().startsWith("Rabbit") ? "amqp" : "kafka";
|
||||
return targetProtocol;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user