spring-framework
spring-framework copied to clipboard
Allow multiple listeners on ResponseBodyEmitter
It looks like the general recommendation about SSE is to send messages at fixed interval to clients to probe the connection health (see https://github.com/spring-projects/spring-framework/issues/18523#issuecomment-470141717).
Should it be the application responsibility (or not, see #33355), in order to track the ResponseBodyEmitter state from multiple application places (the first place being the @Controller where the object is created, the second place being the heartbeat executor), I think ResponseBodyEmitter should allow multiple onTimeout, onError and onCompletion callbacks.
Currently, ResponseBodyEmitter only allows at most one callback per lifecycle event type.