activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <tim.b...@sensis.com>
Subject Re: Amq client crash when losing connection to broker
Date Mon, 12 Nov 2007 16:27:06 GMT
Please upgrade to ActiveMQ-CPP 2.1.1 as this sounds like an error that
we fixed.  Then let us know if it still misbehaves.

Regards
Tim

On Mon, 2007-11-12 at 08:19 -0800, pfid wrote:
> 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?

Mime
View raw message