I have an listener which is listening for UDP packets and after receiving and processing that data want to stream it to a topic (currently Kafka).
I have managed to run a sample program of Spring Cloud Stream Kafka Binder
producer.
@Bean
public Supplier<PacketDataPojo> data() {
return () -> {
PacketDataPojo pdp = new PacketDataPojo(UUID.randomUUID().toString());
log.info("Current data {}", pdp);
return pdp;
};
}
application.properties
spring.cloud.function.definition=data
spring.cloud.stream.bindings.data-out-0.destination=data-stream
Now as it is generating data with some scheduled interval, how can I make Supplier
to stream data after packet processing is completed.
Thanks
I believe the StreamBridge
will do the trick for you - https://docs.spring.io/spring-cloud-stream/docs/3.1.5/reference/html/spring-cloud-stream.html#_sending_arbitrary_data_to_an_output_e_g_foreign_event_driven_sources
So, you may not need Supplier for your case