I've start dipping toes in Spring Cloud Stream and it's Cloud Function support.
I've uploaded a sample project to elucidate this problem here -> https://github.com/nmarquesantos/spring-cloud-function-kafka
I have a project that exposes a few functions in a reactive manner, with kafka as the message broker.
The function receives a Flux and proceeds to save the elements via the Reactive Mongo library. It then returns the updated resource via another flux.
@Service
public class ExampleCloudFunction {
@Autowired
private PlayerRepository playerRepository;
@Bean
public Function<Flux<Player>, Flux<Player>> playerUpdate() {
return flux -> flux.flatMap(player -> playerRepository.save(player)).log("Saved player");
}
@PollableBean
public Supplier<Flux<Player>> playerFeeder() {
return () -> Flux.just(new Player(UUID.randomUUID().toString(), "Ronaldo"));
}
}
The playerUpdate function is where the errors occur. playerFeeder is simply a function I created to send data to reproduce the problem. In real life, this would come from a different service.
Here's a snippet of the errors by running the sample project i mentioned above:
2020-05-21 22:13:40.842 ERROR 1884 --- [container-0-C-1] onfiguration$FunctionToDestinationBinder : Failed to process the following content which will be dropped: Context1{reactor.onNextError.localStrategy=reactor.core.publisher.OnNextFailureStrategy$ResumeStrategy@2c3e726}
org.springframework.transaction.reactive.TransactionContextManager$NoTransactionInContextException: No transaction in context
2020-05-21 22:13:41.853 ERROR 1884 --- [container-0-C-1] onfiguration$FunctionToDestinationBinder : Failed to process the following content which will be dropped: Context1{reactor.onNextError.localStrategy=reactor.core.publisher.OnNextFailureStrategy$ResumeStrategy@2c3e726}
org.springframework.transaction.reactive.TransactionContextManager$NoTransactionInContextException: No transaction in context
I'm struggling to understand what I've done wrong and couldn't find much information in my search.