spring-rabbit не останавливает потоки, он запускается, когда я выключаю 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.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/spring-rabbit.

Это часть моего контекста Spring, связанная с кроликом 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.


person Daniel Kaplan    schedule 17.01.2015    source источник


Ответы (1)


Я исправил это, вручную вызвав applicationContext.destroy() моего Spring в методе уничтожения сервлета.

person Daniel Kaplan    schedule 17.01.2015