I am trying to deploy a simple example from the Spring Cloud function docs in AWS lamba using a function with a reactive type, but get the error:
{
"errorType": "ClassCastException",
"errorMessage": "reactor.core.publisher.FluxMapFuseable cannot be cast to org.springframework.messaging.Message",
"stackTrace": "java.lang.ClassCastException: reactor.core.publisher.FluxMapFuseable cannot be cast to org.springframework.messaging.Message\n\tat org.springframework.cloud.function.adapter.aws.CustomRuntimeEventLoop.eventLoop(CustomRuntimeEventLoop.java:161)\n\tat org.springframework.cloud.function.adapter.aws.CustomRuntimeEventLoop.lambda$run$0(CustomRuntimeEventLoop.java:90)\n\tat java.base@17.0.7/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)\n\tat java.base@17.0.7/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n\tat java.base@17.0.7/java.lang.Thread.run(Thread.java:833)\n\tat org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:775)\n\tat org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:203)\n"
}
If I deploy this locally using gradlew bootRun, there are no issues.
Is there a custom message converter needed to support Reactive types or am I missing a dependency for this to work on AWS lamda? If try this without the reactive types, there are no issues with the Lambda. If so, if someone can provide the logic for the " protected Object convertFromInternal(Message<?> message, Class<?> targetClass, Object conversionHint) {
" method
Example function I am testing with using the input "hello":
@SpringBootApplication
public class Application {
@Bean
public Function<Flux<String>, Flux<String>> uppercase() {
return flux -> flux.map(value -> value.toUpperCase());
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}