GH-1014 Fix CustomRuntimeEventLoop to default to RoutingFunction
Resolves #1014
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
<useDefaultExcludes>true</useDefaultExcludes>
|
||||
<fileMode>0775</fileMode>
|
||||
<includes>
|
||||
<include>native-uppercase</include>
|
||||
<include>function-sample-aws-native</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
@@ -2,17 +2,35 @@ package com.example.demo;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.function.context.DefaultMessageRoutingHandler;
|
||||
import org.springframework.cloud.function.context.MessageRoutingCallback;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
@SpringBootApplication
|
||||
public class NativeUppercaseApplication {
|
||||
|
||||
Log logger = LogFactory.getLog(NativeUppercaseApplication.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(NativeUppercaseApplication.class, args);
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public MessageRoutingCallback customRouter() {
|
||||
return new MessageRoutingCallback() {
|
||||
@Override
|
||||
public String routingResult(Message<?> message) {
|
||||
logger.info("Received message: " + message);
|
||||
return (String) message.getHeaders().get("spring.cloud.function.definition");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<String, String> uppercase() {
|
||||
return v -> {
|
||||
@@ -21,4 +39,12 @@ public class NativeUppercaseApplication {
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<String, String> lowercase() {
|
||||
return v -> {
|
||||
System.out.println("Lowercasing " + v);
|
||||
return v.toUpperCase();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
cd ${LAMBDA_TASK_ROOT:-.}
|
||||
|
||||
./native-uppercase -Dlogging.level.org.springframework=DEBUG
|
||||
./function-sample-aws-native -Dlogging.level.org.springframework=DEBUG
|
||||
|
||||
Reference in New Issue
Block a user