<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'm using JAVA client for RabbitMQ (com.rabbitmq:amqp-client:2.8.1) to write a "jar component" 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 "post" 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 "behind the scene" 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("AMQP Connection " + getHostAddress() + ":" + 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't "daemon" threads. So, when main application ends and appropriate connection closing not occurs, the VM won't terminate. My approach was to add some shutdown hook to close RabbitMQ connections if it is live inside my "jar component". 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>