Hi all and a specially spring team!
How can I pipeline spring-cloud-function with spring-cloud-stream in functional Bean programming model style?
For example I have pom.xml with both dependencies:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-reactive</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-function-webflux</artifactId>
</dependency>
and let's say I would like to do next:
- send via http payload string via spring-cloud-function (webflux)
- uppercase it using my toUpperCase function
- and finally send forward into my pipeline to installed binder (kafka/rabbit/test-binder)
so I'm expecting implement it like so:
@Log4j2
@SpringBootApplication
public class SpringCloudFunctionStreamApplication {
/**
* can I sent result of that function to my broker without any
* explicitly defined output.send(...) execution?
*/
@Bean
public Function<String, String> toUpperCase() {
return arg -> {
var res = arg.toUpperCase();
log.info("toUpperCase: {}", res);
return res;
};
}
public static void main(String[] args) {
SpringApplication.run(
SpringCloudFunctionStreamApplication.class,
"--spring.cloud.function.definition=toUpperCase",
"--spring.cloud.stream.function.definition=toUpperCase"
);
}
}
so when I'm using HTTPie to send a payload, like so:
echo 'hello' | http :8080/toUpperCase
spring-cloud-function seems to works fine, and I can see expected log:
2019-06-09 21:20:36.978 ...SpringCloudFunctionStreamApplication : toUpperCase: hello
same think if I'm publishing message via rabbitmq management web ui, but how I can pipeline from one to another
So my question related to according to spring documentation which says that I can use spring-cloud-stream as well: Wrappers for @Beans of type Function, Consumer and Supplier, exposing them to the outside world as either HTTP endpoints and/or message stream listeners/publishers with RabbitMQ, Kafka etc., but I cannot understand how?
At the moment, unfortunately, I can only manually publish message to spring-cloud-stream binder using Source see example here, but it's of course what I want to know if it's possible to avoid with spring, magically...
Can please anybody tell me (maybe Gary Russell, Dave Sawyer, Artem Bilan, Oleg Zhurakousky or anybody else who knows): what do I missed and how I should configure my app or which props I should add in my application.properties, etc?
Thanks!
Regards, Maksim
http -> function(s) -> rabbitcorrect? - Oleg Zhurakousky