I am using Kafka for a microservices project. I want to invoke an event whenever I save a record to the database. I have been looking at tutorials about Spring Cloud Stream. All of them are using @EnableBinding, @Input, @Output annotations. When I try to use them, it says they are deprecated. I am using spring initialzr. The release notes say that I should use Supplier, Consumer, and Function instead of the old methods like Input, Output, and Process.
@Bean
public Supplier<String> toUpperCase() {
return () -> {
return "hello from supplier";
};
}
When I use a Supplier like this, it generates the message every second as it is also highlighted in the tutorials. I don't want it to be published every second. I want it to be published when I want it to. It says I should invoke its get() method but I don't know how. Tutorials use deprecated functions to achieve such a functionality. How can I achieve such behavior without deprecated functions or how can I use the EnableBinder annotation without it is saying it is deprecated?