当我关闭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.access$600(SimpleMessageListenerContainer.java:78)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1045)
at java.lang.Thread.run(Thread.java:745)
我用这个作为春/兔负责这个问题的证据。
这是我的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>
当我关闭tomcat时,如何告诉spring-rabbit停止创建的线程?
我正在使用spring-rabbit版本1.4.2.RELEASE
答案 0 :(得分:0)
我通过在servlet的destroy方法中手动调用我的Spring applicationContext.destroy()
来解决这个问题。