![]() |
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> Supplier, Function, and ConsumerSCSt 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
Reactive: Java
Construction of Spring Cloud StreamThe program is set up to bind the channels INPUT and OUTPUT specified within the interface Processor by the annotation @EnableBinding. It is possible to set up both channels to utilize a certain message middleware or binder. Java
Functional TestingA binder implementation serving as the test support enables channel interaction and message inspection. Send a message to the mentioned enrichLogMessage service and see if the answer includes the string “[1]:” at the start of the message. Java
Reactive Functions supportYou may use the reactive programming approach in the implementation of Supplier, Function, or Consumer with little effort because Spring Cloud Function is built on top of Project Reactor. Java
ConclusionSo, this is how Spring Cloud Stream – functional and reactive. 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. |
Reffered: https://www.geeksforgeeks.org
Advance Java |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 11 |