【问题标题】:Spring application with JMSListener doesnt shut down带有 JMSListener 的 Spring 应用程序不会关闭
【发布时间】:2015-11-07 18:57:27
【问题描述】:

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

这是来自 intellij 的屏幕截图:

我的代码如下所示:

@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]

【问题讨论】:

  • 你可以在这里粘贴代码吗?
  • ok 添加了我的 jmslistener 的代码
  • @JmsListener 只是处理消息的对象。它不处理线程创建。看起来线程是由 Amazon java 消息处理的。
  • 似乎问题出在JmsListenerEndpointRegistry

标签: java spring tomcat spring-jms


【解决方案1】:

SPR-14233 在 Spring Core 4.2.6 中已修复

【讨论】:

    猜你喜欢
    • 2019-01-08
    • 2016-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-14
    • 1970-01-01
    • 2014-06-07
    相关资源
    最近更新 更多