gpt4 book ai didi

java - 带有 JMS Listener 的 Spring 应用程序不会关闭

转载 作者:行者123 更新时间:2023-11-28 23:28:48 28 4
gpt4 key购买 nike

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

这是来自 intellij 的屏幕截图: enter image description here

这是我的代码:

@Service
public class QueueMsgConsumer
{

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

似乎使用@JmsListener 启动了一个非守护线程,该线程在tomcat 想要关闭时不会停止。

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

更新:

虽然添加带有“setDaemon(true) 的ThreadPoolTask​​Executor”确实会在一分钟左右后最终关闭,但它似乎仍然不够优雅。打开“跟踪”级别的日志记录,我看到了:



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]

最佳答案

SPR-14233已在 Spring Core 4.2.6 中修复

关于java - 带有 JMS Listener 的 Spring 应用程序不会关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33586569/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com