【问题标题】:ActiveMQ Transport Thread is not terminated when main ends主结束时 ActiveMQ 传输线程未终止
【发布时间】:2015-06-24 01:28:31
【问题描述】:

这是我开始连接的方式:

factory = new PooledConnectionFactory(brokerURL);

brokerURL is "failover:(tcp://host1.com:61616,tcp://host2.com:61616)?randomize=false&jms.useAsyncSend=false&jms.dispatchAsync=false&maxReconnectAttempts=30&maxReconnectDelay=3000"

连接开始:

connection = factory.createConnection("", ""); 
connection.start();

应用程序在连接关闭之前执行其通常的任务:

connection.close();

main方法完成了,但是JVM没有,因为还有几个ActiveMQ线程在活动:

Thread [ActiveMQ Transport: tcp://host1.com/ip_address:61616@2455] (Running)    
Daemon Thread [ActiveMQ InactivityMonitor ReadCheckTimer] (Running) 
Daemon Thread [ActiveMQ InactivityMonitor WriteCheckTimer] (Running)    
Daemon Thread [ActiveMQ InactivityMonitor Worker] (Running) 

我应该如何关闭它,以便上面的线程也将关闭。 ActiveMQ 版本 5.10.0

提前致谢

【问题讨论】:

    标签: java multithreading activemq


    【解决方案1】:

    用 (PooledConnectionFactory) factory).stop(); 修复

    【讨论】:

      【解决方案2】:

      或者添加“daemon=true”作为连接url参数。

      根据http://activemq.apache.org/tcp-transport-reference.html

      如果为真,传输线程将以守护模式运行

      即使守护线程正在运行,主 JVM 线程也会退出。

      【讨论】:

        猜你喜欢
        • 2011-02-03
        • 2011-10-06
        • 2012-01-12
        • 2015-02-21
        • 1970-01-01
        • 1970-01-01
        • 2016-01-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多