Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 665451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:42:34+00:00 2026-05-13T23:42:34+00:00

My application uses a Spring DefaultMessageListenerContainer to process incoming messages. The main method of

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:42:34+00:00Added an answer on May 13, 2026 at 11:42 pm

    You can cast your application context to ConfigurableApplicationContext and call close() on it. At least that’s what happens when the context is shut down in a web-application environment, in cases the servlet context is destroyed.

    If you want to get ahold of the ApplicationContext, your bean may implement ApplicationContextAware

    Another option is to inject (or autowire with @Autowired) the application context:

    @Inject
    private ApplicationContext ctx;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSP struts application that uses Spring to integrate with the services/dao/database.
I've deployed an Apache Wicket web-application that uses Spring and Hibernate to my Tomcat
I've set up ehcache on our Java application, which uses Spring and Hibernate. However,
I have a spring application that uses an embedded Jetty instance. Since I am
I'm developing a spring application that uses large MySQL tables. When loading large tables,
In my application which uses spring security I want to define two different areas
I have a web application that uses spring security. It uses <intercept-url ../> elements
I'm writing web application that uses Spring MVC to bind Spring beans with REST-like
Which cache provider is suggested for an application that uses Hibernate3 Spring JSF2
This is a question that has been bothering me for sometime. My application uses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.