Support for non-blocking event listener methods [SPR-17298] #21831
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Mark Paluch opened SPR-17298 and commented
In a non-blocking application flow, it's desirable to prevent event listeners from blocking and yet have a notion of managed event completion (i.e. an event listener needs to interact with a remote system but must not block). Event listener methods could return future/async types so the event multicaster can synchronize on execution/initiate execution to use non-blocking event listeners in a reactive (or at least non-blocking) arrangement.
Event listener methods could either return:
ListenableFuture
,CompletableFuture
, orCompletionStage
, eitherVoid
,T
, orCollection<T>
component types)Publisher
(or any other supported reactive type such as RxJava 2'sObservable
withVoid
orT
component types).Example:
This feature could allow to implement functionality in event listeners in an non-blocking programming model to prevent blocking calls.
Result handles should be used to attach at least some sort of exception handling to prevent exceptions from going unnoticed. For reactive types, the multicaster subscribes to the reactive type to materialize the outcome.
Values emitted from a result handle (i.e. non-void returns like
CompletableFuture<Void>
,Publisher<Void>
) could be emitted again as events.This ticket seems to relate to #21025.
Issue Links:
ApplicationEventPublisher
in a reactive call stack [SPR-16481] #21025 Use of ApplicationEventPublisher in a reactive call stack1 votes, 5 watchers
The text was updated successfully, but these errors were encountered: