spring-rabbit 没有停止它在我关闭时启动的线程 Tomcat

spring-rabbit is not stopping threads it starts when I shutdown Tomcat

当我关闭 tomcat 时,我在日志中收到这些消息并且 JVM 没有释放进程:

Jan 16, 2015 4:20:25 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/myproject] appears to have started a thread named [SimpleAsyncTaskExecutor-1] but has failed to stop it. This is very likely to create a memory leak.
Jan 16, 2015 4:20:25 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/myproject] appears to have started a thread named [pool-1-thread-1] but has failed to stop it. This is very likely to create a memory leak.
Jan 16, 2015 4:20:25 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/myproject] appears to have started a thread named [pool-1-thread-2] but has failed to stop it. This is very likely to create a memory leak.
Jan 16, 2015 4:20:25 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/myproject] appears to have started a thread named [pool-1-thread-3] but has failed to stop it. This is very likely to create a memory leak.
Jan 16, 2015 4:20:25 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/myproject] appears to have started a thread named [SimpleAsyncTaskExecutor-1] but has failed to stop it. This is very likely to create a memory leak.
Jan 16, 2015 4:20:25 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/myproject] appears to have started a thread named [pool-1-thread-4] but has failed to stop it. This is very likely to create a memory leak.

我使用调试器查看这些线程在关闭前在做什么,这是它们的线程转储之一:

"SimpleAsyncTaskExecutor-1@4510" prio=5 tid=0x29 nid=NA waiting
java.lang.Thread.State: WAITING
at sun.misc.Unsafe.park(Unsafe.java:-1)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.nextMessage(BlockingQueueConsumer.java:302)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doReceiveAndExecute(SimpleMessageListenerContainer.java:945)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.receiveAndExecute(SimpleMessageListenerContainer.java:934)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access0(SimpleMessageListenerContainer.java:78)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1045)
at java.lang.Thread.run(Thread.java:745)

我用这个作为 spring/spring-rabbit 对这个问题负责的证据。

这是我的 Spring 上下文中与 rabbit mq 有关的部分:

<rabbit:connection-factory id="connectionFactory" host="host" port="5672" username="username" password="password" virtual-host="/projectname"/>

<rabbit:admin connection-factory="connectionFactory"/>
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory" exchange="barExchange"/>

<rabbit:queue name="barQueueCleanDev" />
<rabbit:queue name="barQueueFooDev" />

<rabbit:topic-exchange name="barExchange" >
<rabbit:bindings>
<rabbit:binding queue="barQueueFooDev" pattern="bar.queue.foo.dev" />
<rabbit:binding queue="barQueueCleanDev" pattern="bar.queue.clean.dev" />
</rabbit:bindings>
</rabbit:topic-exchange>

<rabbit:listener-container connection-factory="connectionFactory" acknowledge="auto" concurrency="1" max-concurrency="1" requeue-rejected="false" error-handler="barServiceErrorHandler">
<rabbit:listener ref="barService" method="create" queue-names="barQueueCleanDev"/>
<rabbit:listener ref="barService" method="createFromFoo" queue-names="barQueueFooDev"/>
</rabbit:listener-container>

如何告诉 spring-rabbit 在我关闭 tomcat 时停止它创建的线程?

我正在使用 spring-rabbit 版本 1.4。2.RELEASE

我通过在 servlet 的销毁方法中手动调用我的 Spring 的 applicationContext.destroy() 来解决这个问题。