ActiveMQ-当我想停止Java进程时,它保持活动状态

时间:2019-02-26 11:12:21

标签: java multithreading process activemq shutdown

我有一个连接到ActiveMQ(作为使用者)的Java进程。当我尝试彻底停止它时,它会引起问题。

该过程如下停止:

  • 收到控制消息,要求停止该过程
  • 使用者,会话和连接已关闭,等待已接收到的所有消息得到处理
  • 最终日志消息已打印
  • 进程关闭并且不再存在

如果尚未处理任何消息,则该过程似乎可以正常关闭。但是一旦收到消息,该过程就不会停止,而且我不确定为什么(最终的日志消息已打印)

我已经打印了一个线程转储以查看发生了什么,但是我不确定是什么导致了该问题:

Attaching to process ID 17264, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.201-b09
Deadlock Detection:

No deadlocks found.

Thread 20: (state = BLOCKED)
 - java.lang.Object.wait(long) @bci=0 (Interpreted frame)
 - java.lang.ref.ReferenceQueue.remove(long) @bci=59 (Compiled frame)
 - java.lang.ref.ReferenceQueue.remove() @bci=2 (Compiled frame)
 - sun.java2d.Disposer.run() @bci=3 (Interpreted frame)
 - java.lang.Thread.run() @bci=11 (Interpreted frame)

Locked ownable synchronizers:
    - None

Thread 19: (state = BLOCKED)
 - sun.misc.Unsafe.park(boolean, long) @bci=0 (Interpreted frame)
 - java.util.concurrent.locks.LockSupport.parkNanos(java.lang.Object, long) @bci=20 (Interpreted frame)
 - java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(long) @bci=78 (Interpreted frame)
 - java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take() @bci=124 (Interpreted frame)
 - java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take() @bci=1 (Interpreted frame)
 - java.util.concurrent.ThreadPoolExecutor.getTask() @bci=149 (Interpreted frame)
 - java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=26 (Interpreted frame)
 - java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5 (Interpreted frame)
 - java.lang.Thread.run() @bci=11 (Interpreted frame)

Locked ownable synchronizers:
    - None

Thread 18: (state = BLOCKED)
 - sun.misc.Unsafe.park(boolean, long) @bci=0 (Interpreted frame)
 - java.util.concurrent.locks.LockSupport.parkNanos(java.lang.Object, long) @bci=20 (Interpreted frame)
 - java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(long) @bci=78 (Interpreted frame)
 - java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take() @bci=124 (Interpreted frame)
 - java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take() @bci=1 (Interpreted frame)
 - java.util.concurrent.ThreadPoolExecutor.getTask() @bci=149 (Interpreted frame)
 - java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=26 (Interpreted frame)
 - java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5 (Interpreted frame)
 - java.lang.Thread.run() @bci=11 (Interpreted frame)

Locked ownable synchronizers:
    - None

Thread 17: (state = BLOCKED)
 - java.lang.Object.wait(long) @bci=0 (Interpreted frame)
 - java.util.TimerThread.mainLoop() @bci=201 (Interpreted frame)
 - java.util.TimerThread.run() @bci=1 (Interpreted frame)

Locked ownable synchronizers:
    - None

Thread 1: (state = BLOCKED)

Locked ownable synchronizers:
    - None

Thread 10: (state = BLOCKED)

Locked ownable synchronizers:
    - None

Thread 9: (state = BLOCKED)

Locked ownable synchronizers:
    - None

Thread 8: (state = BLOCKED)
 - java.lang.Object.wait(long) @bci=0 (Interpreted frame)
 - java.lang.ref.ReferenceQueue.remove(long) @bci=59 (Compiled frame)
 - java.lang.ref.ReferenceQueue.remove() @bci=2 (Compiled frame)
 - java.lang.ref.Finalizer$FinalizerThread.run() @bci=36 (Interpreted frame)

Locked ownable synchronizers:
    - None

Thread 7: (state = BLOCKED)
 - java.lang.Object.wait(long) @bci=0 (Interpreted frame)
 - java.lang.Object.wait() @bci=2 (Compiled frame)
 - java.lang.ref.Reference.tryHandlePending(boolean) @bci=54 (Compiled frame)
 - java.lang.ref.Reference$ReferenceHandler.run() @bci=1 (Interpreted frame)

Locked ownable synchronizers:
   - None

据我所见

  • 线程8/20是垃圾收集器,正在等待收集某些东西
  • 线程7也链接到垃圾收集器
  • 线程18/19 ???
  • 线程17是Timer实例,不确定谁启动了它

ActiveMQ版本: 5.15.4

ActiveMQConnectionFactory网址:故障转移:(tcp:// localhost:61616)?timeout = 3000&maxReconnectAttempts = 10

没有其他特定参数

0 个答案:

没有答案