Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StreamMessageListenerContainer should wait until listeners finish processing within timeout during shutdown #2261

Open
lrozek opened this issue Feb 15, 2022 · 5 comments
Labels
type: enhancement A general enhancement

Comments

@lrozek
Copy link

lrozek commented Feb 15, 2022

when spring boot application is being shutdown gracefully, DefaultStreamMessageListenerContainer should wait until listeners have finished their processing within given timeout. Currently redis stream listeners are terminated instantly in the middle of the listener handler without giving them a chance to finish

Similar functionality is offered for RabbitMQ listeners (https://github.com/spring-projects/spring-amqp/blob/main/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/SimpleMessageListenerContainer.java#L634) and JMS listeners (https://www.amitph.com/spring-boot-graceful-shutdown/#JMS_Listener)

repro project can be found here https://github.com/lrozek/redis-listener-graceful-shutdown

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 15, 2022
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 16, 2022
@mp911de mp911de changed the title StreamMessageListenerContainer should wait until listeners finish processing within timeout during shutdown StreamMessageListenerContainer should wait until listeners finish processing within timeout during shutdown Feb 16, 2022
@mp911de
Copy link
Member

mp911de commented Feb 16, 2022

Thanks for raising the topic. It makes sense to await completion in the stop method to avoid any races or connection errors because the connection is closed while still in use.

@lrozek
Copy link
Author

lrozek commented Feb 16, 2022

@mp911de the point was rather to allow graceful shutdown of redis listener to finish its processing instead of terminating abruptly, which could lead to data being lost or corrupted.

Races and connections errors that you mentioned I also encountered during shutdown, however I intended to report it as a separate issue.

@lrozek
Copy link
Author

lrozek commented Feb 16, 2022

@mp911de I reported relevant race conditions in #2262

@MrNocTV
Copy link

MrNocTV commented Oct 10, 2022

Hi, I have the same problem with @lrozek that also posted here on stackoverflow. https://stackoverflow.com/questions/74003013/spring-boot-web-socket-message-broker-shutdown-before-redis-stream

It's kinda similar. The application needs to process all remaining messages and only then terminated.
Cant find any workaround at the moment :(
With this bug I don't think spring-data-redis is production ready.

@aooohan
Copy link

aooohan commented Apr 20, 2023

@mp911de Hi, I have tried to fix this issue. Please review #2563, let me if any improvement need do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants