<span style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Hi,</span><div style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:13px;background-color:rgb(255,255,255)">I&#39;m using JAVA client for RabbitMQ (com.rabbitmq:amqp-client:2.8.1) to write a &quot;jar component&quot; capable of sending messages for some legacy system. The idea is to wrap all code that maintain the connection inside my component. This way, the client software deals only with very simple methods like &quot;post&quot; and is not aware of any connection handling. The connect/reconnect code is written and hidden from the legacy system.</div>
<div style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
The problem I have faced is that Java client creates &quot;behind the scene&quot; some threads to manage connection - like:</div><div style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
         lines 299-301 of AMQConnection class.<br></div><div style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<div style="margin:0px;padding:0px;border:0px;vertical-align:baseline">        // start the main loop going</div><div style="margin:0px;padding:0px;border:0px;vertical-align:baseline">        new MainLoop(&quot;AMQP Connection &quot; + getHostAddress() + &quot;:&quot; + getPort()).start();</div>
<div style="margin:0px;padding:0px;border:0px;vertical-align:baseline">        // after this point clear-up of MainLoop is triggered by closing the frameHandler.</div></div><div style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Unfortunatelly, those threads aren&#39;t &quot;daemon&quot; threads. So, when main application ends and appropriate connection closing not occurs, the VM won&#39;t terminate. My approach was to add some shutdown hook to close RabbitMQ connections if it is live inside my &quot;jar component&quot;. But, due to those non-daemon threads, VM is not going ever to be terminated and shutdown hooks fired.</div>
<div style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
It is a question to RabbitMQ driver developers, if the internal threads could be fired as daemon threads, could it be done in future releases?</div><div><br></div>