Reputation: 3381
Is there a way to live stream data using spring-data-cassandra? Basically, I want to send data to client whenever there is a new addition to the database.
This is what I'm trying to do:-
@GetMapping(path = "mapping", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<Mapping> getMapping() {
Flux<Mapping> flux = reactiveMappingByExternalRepository.findAll();
Flux<Long> durationFlux = Flux.interval(Duration.ofSeconds(1));
return Flux.zip(flux, durationFlux).map(Tuple2::getT1);
}
But it doesn't return once the stream is complete.
Upvotes: 1
Views: 484
Reputation: 18129
The short answer is no, there's no live-streaming of real-time changes through the Cassandra driver. Although Cassandra has a CDC (Change Data Capture), it's quite low-level and you need to consume commit logs on the server. See Listen to a cassandra database with datastax for further details.
Upvotes: 1