Announcement Announcement Module
Collapse
No announcement yet.
registerShutdownHook not waiting for a thread to complete Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • registerShutdownHook not waiting for a thread to complete

    Hi,

    I have a stand-alone spring application, and I am trying to test the behaviour of graceful shutdown by using registerShutdownHook feature. I see that the application waits for all current processes to complete once i shutdown the application. The only exception is a poller thread and it dies halfway although the @Predestroy method is being invoked in that class.

    I have the following definition in beans.xml

    Code:
    <bean 
    	  id="scheduledTasks" 
    	  class="org.springframework.scheduling.timer.TimerTaskExecutor"> 
    	  <property name="timer"> 
    	   <bean 
    	    class="org.springframework.scheduling.timer.TimerFactoryBean"> 
    	    <property name="scheduledTimerTasks"> 
    	     <list> 
    	      <bean 
    	       class="org.springframework.scheduling.timer.ScheduledTimerTask" 
    	       p:runnable-ref="myPoller" /> 
    	     </list> 
    	    </property> 
    	   </bean> 
    	  </property> 
    	 </bean>
    In the above fragemetn myPoller simply implements Runnable interface. I have put a short sleep in the run method and placed a log statement before and after the sleep. While it is sleeping I have the killed the process, it never resumes the statement after the sleep statement.

    Ideally, I was hoping the application will not shutdown until the thread completes it business.

    Thanks.
Working...
X