activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pfid>
Subject Amq client crash when losing connection to broker
Date Mon, 12 Nov 2007 16:19:52 GMT

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

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"
"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
however, connection->close() on this broken connection will just hang
forever, and the application wont be able to close/remove/delete this

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

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

      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:
Sent from the ActiveMQ - User mailing list archive at

View raw message