The ActiveMQ transport topic doesn't end when the main ends

This is how I start the connection:

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 started:

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

      

The application performs its normal tasks until the connections are closed:

connection.close();

      

the main method is complete, but the JVM is not, because there are still several active ActiveMQ threads:

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) 

      

How should I close it so that the threads above are turned off. ActiveMQ version 5.10.0

early

+3


source to share


2 answers


Fixed with (PooledConnectionFactory) factory). stop ();



+1


source


Or add "daemon = true" as the connection url parameter.

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



If true, the transport stream will be started in daemon mode

The main JVM thread will exit even if the daemon threads are running.

0


source







All Articles