Supplier, Function, and Consumer

SCSt treats any bean of type Supplier, Function, or Consumer as a message handler (Function or Consumer) or message source (Supplier), or any bean that may be mapped to Supplier, Function, or Consumer (e.g., a POJO function, Kotlin lambdas, and so forth). Input and output bindings are automatically produced using the <function-name>-<in/out>-<index> naming standard, depending on the type of functional strategy that is being utilized.

Functional:

Java




@SpringBootApplication
public class GFG  {
    @Bean
    public Function<String, String> uppercase() {
        return value -> value.toUpperCase();
    }
}


Reactive:

Java




@SpringBootApplication
public class GFG  {
    @Bean
    public Function<Flux<String>, Flux<String>> uppercase() {
        return flux -> flux.map(value -> value.toUpperCase());
    }
}


Spring Cloud Stream – Functional and Reactive

Spring Cloud Stream is a Spring framework that simplifies creating event-driven microservices. It uses functional programming constructs for message processing logic, often using annotated methods within a class and reactive programming tools like Reactor for asynchronous and reactive processing.

Maven Dependencies

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
<version>3.1.3</version>
</dependency>

Similar Reads

Supplier, Function, and Consumer

SCSt treats any bean of type Supplier, Function, or Consumer as a message handler (Function or Consumer) or message source (Supplier), or any bean that may be mapped to Supplier, Function, or Consumer (e.g., a POJO function, Kotlin lambdas, and so forth). Input and output bindings are automatically produced using the -- naming standard, depending on the type of functional strategy that is being utilized....

Construction of Spring Cloud Stream

...

Conclusion

...

Contact Us