activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Tarau <adrian.ta...@gmail.com>
Subject Transport Exceptions close the connection
Date Mon, 21 May 2007 16:22:55 GMT

Hello,

I have the following problem : A connection(embedded broker, vm transport)
is created and then a few sessions. I poll for messages, with my own threads
in order to do throttling. One thing that confuses me is : if an exception
occurs somewhere in the transport(for example an interrupt on the consuming
thread) , the connection is closed with all the sessions and
consumers/producers.

I was able to listen for such an exceptions(with
Connection.setExceptionListener(...)) and recreate the connection. I tried
also with connectionFactory.setBrokerURL("failover:vm://localhost") which
supposed to fix problems like this one, and to reconnect, but is not working
as espected.

I have Active MQ 4.0.2.

ActiveMQConnections fragments : 

protected void transportFailed(IOException error){
        transportFailed.set(true);
        if (firstFailureError == null) {
            firstFailureError = error;
        }
        if (!closed.get() && !closing.get()) {
            try{
                cleanup(); close all sessions
            }catch(JMSException e){
               log.warn("Cleanup failed",e);
            }
        }
    }

 public void onException(final IOException error) {
        onAsyncException(error);
        asyncConnectionThread.execute(new Runnable(){
            public void run() {
                transportFailed(error);
                ServiceSupport.dispose(ActiveMQConnection.this.transport);
                brokerInfoReceived.countDown();
        
                for (Iterator iter = transportListeners.iterator();
iter.hasNext();) {
                    TransportListener listener = (TransportListener)
iter.next();
                    listener.onException(error);
                }
            }
        });
    }

Thanks.
-- 
View this message in context: http://www.nabble.com/Transport-Exceptions-close-the-connection-tf3791363s2354.html#a10722140
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message