How can I create producer in Spring Cloud Stream Functional Model?
The following version is deprecated now.
@Output(OUTPUT)
MessageChannel outbound();
I know that it is possible to achieve by java Supplier
functional class, but it will send message every one second. I don't need it to send every second. I am going to replace REST API with with Kafka.
Are there any ways to do that?
Use the StreamBridge
- see Sending data to an arbitrary output.
Here we autowire a
StreamBridge
bean which allows us to send data to an output binding effectively bridging non-stream application withspring-cloud-stream
. Note that preceding example does not have any source functions defined (e.g.,Supplier
bean) leaving the framework with no trigger to create source bindings, which would be typical for cases where configuration contains function beans. So to trigger the creation of source binding we usespring.cloud.stream.source
property where you can declare the name of your sources.