activemq-users mailing list archives

Hello, I have been experimenting with the newly released C++ Client for
ActiveMQ. I am very impressed with Nathan Mittlers efforts and I am
experimenting with integrating it into an existing software project. While
testing it, I found a problem.
I have a problem with the ActiveMQConnection object. This problem is
repeatable with the example "main.cpp". In the example, in the function
test(), if the ActiveMQ Server is shut down before you call the following
sequence of commands, the ActiveMQConnection::close() function will throw an
IOException.
64: delete publisher;
65: subscriber->close();
66: delete subscriber;
67: session->close();
68: delete session;
69: connection->close();
70: delete connection;
71: delete connectionFactory;
This can be handled and dealt with easily until it comes time to destroy the
ActiveMQConnection object, which also calls the close function. If the
exception is not caught and handled, the destructor will throw the exception
and not reach its closing curly brace '}'. I am still working on where
the correct place to catch this exception, but we must ensure that all the
resources are cleaned up. Below is the trace which leads to where this occurs.
ActiveNQConnection::~ActiveNQConnection
ActiveMQConnection::close()
StompTransport::close()
StompTransport::sendMessage()
StompIO::writeStompFrame()
StompIO::flush()
BufferedOutputStream::flush()
SocketStream::write() - This is where the exception is thrown from.
In StompTransport::close() - StompTransport.cpp LINE 151 there is one place
which might shed some light as to where the logic of the code should be
altered.
151: if( socket.isConnected() ){
152:
153: DisconnectMessage msg;
154: sendMessage( &msg );
155:
156: // We have to close the streams first because they
157: // depend on the socket streams.
158: if( stompIO != NULL ){
159: stompIO->close();
160: }
161:
162: // Now we can close the socket.
163: socket.close();
164: }
Obviously the connection no longer works, but we enter this block and call
sendMessage(), which is where the exception is thrown from.