2015-11-07 142 views
0

我有一个运行在Tomcat上的Spring应用程序。 当我试图关闭它,似乎并没有这样做。JMSListener的Spring应用程序不关闭

这里是的IntelliJ截图: enter image description here

这里是我的代码如下所示:

@Service 
public class QueueMsgConsumer 
{ 

    @JmsListener(destination = Keys.QUEUE_NAME) 
    public void processMsg(TextMessage message) 
    { 
     //do stuff 
    } 
} 

看来,使用@JmsListener启动非守护线程不停止当Tomcat想要关机。

关闭我的应用程序的正确方法是什么?

更新:

虽然加入了ThreadPoolTaskExecutor' with 'setDaemon(true)并导致一分钟左右后,最终关闭,这似乎仍然是不优雅。打开“追踪”级别的日志我看到这一点:

11:46:04,190 INFO localhost-startStop-1 support.DefaultLifecycleProcessor:356 - Stopping beans in phase 2147483647 
11:46:04,191 DEBUG localhost-startStop-1 support.DefaultLifecycleProcessor:226 - Asking bean 'org.springframework.jms.config.internalJmsListenerEndpointRegistry' of type [class org.springframework.jms.config.JmsListenerEndpointRegistry] to stop 
11:46:34,197 WARN localhost-startStop-1 support.DefaultLifecycleProcessor:373 - Failed to shut down 1 bean with phase value 2147483647 within timeout of 30000: [org.springframework.jms.config.internalJmsListenerEndpointRegistry] 
+0

你能在这里粘贴代码吗? – luboskrnac

+0

ok添加了我的jmslistener的代码 – pdeva

+1

'@ JmsListener'只是处理消息的对象。它不处理线程创建。它看起来像线程由Amazon Java消息处理。 –

回答