问题
TL;DR;
Is it possible to listen on changes through spring-webflux & spring reactive data ?
End of TL;DR;
Hi, I did few tutorials regarding new spring webflux module and spring mongo reactive.
(correct me If I'm wrong)
There are two basic types in reactive spring, Mono (for 0 or single object) and Flux (0 - n) objects.
If I return a Flux json object ( a list of all comments) then my client is going to receive them in one response (not in chunks or something). I did it here,
I also can change return application/type header to an event stream and then each record will be returned in separate chunks to my client. I did it here
Now I'm wondering, would it be possible with such reactive tools to somehow listen on changes which are happening in my database?
I did my client in angular 5 and I'd like to have some sort of real time web app.
I tried such feature in firebase storage and it worked really great but I'm wondering if it's possible to do it in spring reactive.
If not then what's the best approach for building real time rest in spring?
回答1:
You can be notified of new documents added to a MongoDB capped collection, with Spring Data MongoDB @Tailable
support (see reference documentation).
I don't think you get notified of other changes, though (documents deleted or updated).
来源:https://stackoverflow.com/questions/48570387/listen-on-changes-through-spring-webflux-and-spring-reactive-data