What is Spring MVC Based on Reactor? -
i have been reading can spring , reactor , realize reactor supposed included in upcoming spring framework 5 (anyone using in production btw?)
my interest use in spring mvc, since not part of framework, how can reactor used in spring mvc? appears online examples use reactor in spring while waiting framework 5, use reactor-bus.
is spring mvc + reactor in current state adding reactor-bus mvc app ?
a @ github shows reactor-bus seems in legacy mode ?
what current way give reactive capabilities existing spring mvc ?
spring 5 , webflux give benefit, because framework using reactive programming , non-blocking, opportunities end-to-end asynchronicity if db async-capable (think cassandra, redis, mongodb, couchbase, along reactive spring data kay).
that said, library reactor can have benefits if app not reactive. example, if have service layer lot of orchestration needed. if these services represent tasks asynchronous types (ideally flux
/mono
/publisher
, future
), can bridge them reactor , use powerful operators build complex asynchronous processing pipelines.
the last piece let spring 4.x work these asynchronous results. framework has form of support in deferredresult<t>
type, obtain flux
or mono
(the example below simplistic , doesn't show composition of operators mentioned above, hidden in service):
@getmapping() public deferredresult<user> getcurrentuser() { deferredresult<user> result = new deferredresult(); mono<user> mono = myservice.getcurrentuser(); mono.subscribe( value -> result.setresult(value), error -> result.seterrorresult(error) ); return result; }
Comments
Post a Comment