Results 1 to 10 of 17

Thread: DefaultMessageListenerContainer not shutting down

Hybrid View

  1. #1
    Join Date
    Apr 2007
    Posts
    11

    Default DefaultMessageListenerContainer not shutting down

    I know there have been other threads about this but none which have helped. I am using tomcat, activemq and using an Message driven pojo via DefaultMessageListenerContainer.

    Everything is fine except that tomcat does not shutdown gracefully (the process hangs). If I remove the MDP from spring config everything works fine which means it is definately the MDP hence DefaultMessageListenerContainer. From my debugging I can see that the MDP thread is still hanging around while all most other tomcat threads have stopped.

    Has anyone come across this and/or solved it?

  2. #2
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    452

    Default

    Hello,

    do you use the Webapplicationcontext with a ServletContextListener in your enviroment ?
    Normally when the applicationcontext stops, the defaultmesaagelistenercontainer also stops.

    Regards
    agim

  3. #3
    Join Date
    Apr 2007
    Posts
    11

    Default

    Not sure what you mean - but in my web.xml I have the following -

    <!-- Listeners -->
    <listener>
    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    </listener>

    I can see in the logs that it tries to shutdown but the process doesn't die it seems.

  4. #4
    Join Date
    May 2006
    Posts
    13

    Default DMLC not shutting down

    Did you try Spring 2.0.4 and above?

  5. #5
    Join Date
    May 2007
    Location
    Massachusets, USA
    Posts
    30

    Exclamation Think through this.

    Its a guess. Think through this.

    ContextLoaderListener - is an implementation to load the spring context via the web.xml. But it may not be the responsibility of the web container to call the close() or destroy() method on the ApplicationContext that was created by the web container. I dont think it's happening. So you may need to grab the Application context being in a ServletContextListener.destroy() and call applicationContext.close() method. Hopefully that will bring down your Spring beans and will fire the destroy methods on all spring managed beans.

    Check it out.

  6. #6
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    452

    Default

    ContextLoaderListener - is an implementation to load the spring context via the web.xml. But it may not be the responsibility of the web container to call the close() or destroy() method on the ApplicationContext that was created by the web container. I dont think it's happening.
    I think you're worong, have a look at ContextLoaderLister (destroy method)

    Code:
    public void contextDestroyed(ServletContextEvent event) {
    		if (this.contextLoader != null) {
    			this.contextLoader.closeWebApplicationContext(event.getServletContext());
    		}
    }
    closeWebbapplicationContext calls close on the applicationcontexts. So normally with the ContextLoaderListener you should be fine with the MEssageListenerContainer.


    @alvins

    Do you use any (custom ) receiveTimeout in your MessageListenerContainer

    regards
    agim

  7. #7
    Join Date
    Oct 2007
    Posts
    4

    Cool How to Stop and Start active DMLC thread in spring?

    Hi,
    i have an application in which DefaultmessageListenerContainer starts listening on JMS and processes incomming messages.

    In event of too many messages being unprocessed, i would like to shutdown my listeners until I fix the problem and then start the listeners again.

    i tried using teh shutdown(0 and initialise() methods of DefaultMessageListenerContainer, but it is shutting down all my spring beans including the caller bean itself.

    is tehre another way i can do this?

    appreciate your help
    thank you
    kaushik

  8. #8
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    452

    Default

    Hi,

    i tried using teh shutdown(0 and initialise() methods of DefaultMessageListenerContainer, but it is shutting down all my spring beans including the caller bean itself.
    how do you initialize the applicationcontext ?
    I would suggest to use the start and stop methods for starting/stopping the defaultmessagelistenercontainer.

    rgds
    agim

  9. #9
    Join Date
    Oct 2007
    Posts
    4

    Default

    Hi,

    I get the application context using ApplicationContextAwareInterface which returns me teh refeference to the original singleton bean that was defined in spring-config.xml file.

    I tried using start and stop as well, but same result- all singleton's getting destroyed including my caller bean which also exists in same application context.


    kaushik

  10. #10
    Join Date
    Mar 2008
    Posts
    1

    Default In fact, the person have told u.

    just set the timeout, it will be ok.


    <property name="receiveTimeout" value="300"/>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •