Best way to force Spring shutdown from a bean?
Posted
by xcut
on Stack Overflow
See other posts from Stack Overflow
or by xcut
Published on 2010-03-08T12:55:17Z
Indexed on
2010/03/21
18:01 UTC
Read the original article
Hit count: 200
My application uses a Spring DefaultMessageListenerContainer
to process incoming messages. The main method of the app already registers a shutdown hook.
Question is this: what is the best way to force the application context to shut down?
If I throw a RuntimeException
in the message listener, it is handled by the container, and not passed on. Is calling System.exit acceptable? Do I pass along the ApplicationContext
to every class that needs to shut down, so I can call close()
on it?
© Stack Overflow or respective owner