GH-1852 Fix issue with 'output' channel

- This fix addresses the issue where framework assumed the existance of 'output' channel where it is not always the case
 - It also addresses the binary relationship of annotation-based and functional model where you can use one or the other, meaning
 functions will not work with annotation-based bindings with the exception of composing to the existing output (e.g., existing legacy app)
 - It alos upgrades reactor to Dysprosium-SR1

 Resolves #1852
This commit is contained in:
Oleg Zhurakousky
2019-12-02 12:03:37 +01:00
parent 253f3d6547
commit a2dc34a160
3 changed files with 9 additions and 9 deletions

View File

@@ -23,7 +23,7 @@
</scm>
<properties>
<java.version>1.8</java.version>
<reactor.version>Californium-SR11</reactor.version>
<reactor.version>Dysprosium-SR1</reactor.version>
<objenesis.version>2.1</objenesis.version>
<spring-cloud-function.version>3.0.0.RELEASE</spring-cloud-function.version>
<maven-checkstyle-plugin.failsOnError>true</maven-checkstyle-plugin.failsOnError>

View File

@@ -339,10 +339,14 @@ public class FunctionConfiguration {
messageChannel = this.context.getBean(channelName, SubscribableChannel.class);
}
else {
// could be "input" or "output" if subscribing to existing Source
messageChannel = this.context.containsBean("input")
? this.context.getBean("input", SubscribableChannel.class)
: this.context.getBean("output", SubscribableChannel.class);
if (this.context.containsBean("input")) {
logger.info("@EnableBinding way of defining channels is not supported by functions, so 'input' "
+ "channel will not be bound to any existing function beans. You may safely ignore this "
+ "message if that was not your intention otherwise, please remove @EnableBinding annotation.");
}
if (this.context.containsBean("output")) { // need this to compose to existing sources
messageChannel = this.context.getBean("output", SubscribableChannel.class);
}
}
return messageChannel;
}

View File

@@ -36,8 +36,6 @@ import org.springframework.cloud.stream.binder.test.InputDestination;
import org.springframework.cloud.stream.binder.test.OutputDestination;
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
import org.springframework.cloud.stream.converter.CompositeMessageConverterFactory;
import org.springframework.cloud.stream.messaging.Processor;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -176,7 +174,6 @@ public class GreenfieldFunctionEnableBindingTests {
}
@EnableAutoConfiguration
@EnableBinding(Processor.class)
public static class ProcessorFromFunction {
@Bean
@@ -187,7 +184,6 @@ public class GreenfieldFunctionEnableBindingTests {
}
@EnableAutoConfiguration
@EnableBinding(Sink.class)
public static class SinkFromConsumer {
@Bean