I'm using ActiveMQ-CPP 2.1 in my client application, and the broker version
4.1.1.

in case the client loses its connection to the activemq broker, i want it to
close all activemq queue connections, and try to reopen them if possible.

i simulate this behaviour by stopping the broker via ctrl+c while the client
is connected to it. in both, read and send mode, the client will notice the
broken connection successfully with the ::onException(const
cms::CMSException& ex) method. I'll get the error:
"activemq::io::SocketInputStream::read - The connection is broken"
or
"OpenWireConnector::onCommand - Broker closed this connection."
(what message i get is somewhat random)

So far this is fine, i'll just catch the exception and close all
connections. 
however, connection->close() on this broken connection will just hang
forever, and the application wont be able to close/remove/delete this
connection.

   try
   {
      if (session) 
         session->close();
      if (connection)
      {
         connection->stop();
         connection->close();
      }
   }catch (CMSException& e) { printf("Error: '%s'\n",
e.getMessage().c_str()); status = fail;}

   try
   {
      if (session) 
         delete session;
   }catch (CMSException& e) { printf("Error: '%s'\n",
e.getMessage().c_str()); status = fail;}
   session = 0;

   try
   {
      if (connection) 
         delete connection;
   }catch (CMSException& e) { printf("Error: '%s'\n",
e.getMessage().c_str()); status = fail;}
   connection = 0;

if i decide not to close the connection, and just delete it instead (its
broken anyway), the "delete connection" part will hang forever instead,
resulting in the same problem.

so far i haven't found out what is causing this. for some reason, i don't
get this problem when i first try to write this broken connection, and then
close() / delete when i get a write error ("response from futureResponse was
invalid"). this won't help me however, since
1) i would like to close the connection immediately once i notice the
exception, not after the first try to write this broken connection fails
2) i have read-mode connections as well, i can't write on those

could someone help me on this?
-- 
View this message in context: 
http://www.nabble.com/Amq-client-crash-when-losing-connection-to-broker-tf4792112s2354.html#a13708604
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to