Simplified RoutingFunction configuration

If routing-expression is provided there is no need to explicitely set function.definition to 'functionRouter'
This commit is contained in:
Oleg Zhurakousky
2021-02-18 15:35:26 +01:00
parent 81d6998635
commit 7c216847b2
3 changed files with 38 additions and 9 deletions

View File

@@ -32,6 +32,7 @@ import reactor.core.publisher.Mono;
import org.springframework.cloud.function.context.FunctionCatalog;
import org.springframework.cloud.function.context.FunctionProperties;
import org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry.FunctionInvocationWrapper;
import org.springframework.cloud.function.context.config.RoutingFunction;
import org.springframework.core.MethodParameter;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.ReactiveAdapterRegistry;
@@ -154,6 +155,9 @@ class FunctionRSocketMessageHandler extends RSocketMessageHandler {
@SuppressWarnings("unchecked")
private String discoverAndInjectDestinationHeader(Message<?> message) {
String destination = this.functionProperties.getDefinition();
if (!StringUtils.hasText(destination) && StringUtils.hasText(this.functionProperties.getRoutingExpression())) {
destination = RoutingFunction.FUNCTION_NAME;
}
Map<String, Object> headersMap = (Map<String, Object>) ReflectionUtils
.getField(this.headersField, message.getHeaders());