activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mathieu Baril (JIRA)" <j...@apache.org>
Subject [jira] Created: (AMQ-2326) Using connection pool, ActiveMQConnection is not started if an error occur during first attempt to start the connection.
Date Thu, 16 Jul 2009 15:44:33 GMT
Using connection pool, ActiveMQConnection is not started if an error occur during first attempt
to start the connection.
------------------------------------------------------------------------------------------------------------------------

                 Key: AMQ-2326
                 URL: https://issues.apache.org/activemq/browse/AMQ-2326
             Project: ActiveMQ
          Issue Type: Bug
    Affects Versions: 5.2.0
            Reporter: Mathieu Baril


calling start() on org.apache.activemq.pool.PooledConnection do the following:
   
   public void start() throws JMSException {
        if (started.compareAndSet(false, true)) {
            connection.start();
        }
    }

If an error occurs during call on the underlying connection, the value of started is equal
to true. This means that the next call to the start method of the pooled connection will not
call start on the underlying connection even if in reality the connection is not started...

In my case, I use FailoverTransport but I want that my call to start returns after a certain
delay so I interrupt the Thread that is starting the ActiveMQConnection. Doing that, the method
returns but the isStarted method on the ActiveMQConnection returns false. The result is that
all MessageDispatchChannel created on that connection are not started and don't dispatch message
received.

ActiveMQConnection: 
   public void start() throws JMSException {
        checkClosedOrFailed();
        ensureConnectionInfoSent();           => The thread is interrupted here....
        if (started.compareAndSet(false, true)) {
            for (Iterator<ActiveMQSession> i = sessions.iterator(); i.hasNext();) {
                ActiveMQSession session = i.next();
                session.start();
            }
        }
    }


This is the solution that I propose and that seems to work for me:
In PooledConnection, replace:
    public void start() throws JMSException {
        if (started.compareAndSet(false, true)) {
            connection.start();
        }
    }

by

    public void start() throws JMSException {
        started.compareAndSet(false, true);
        if (!connection.isStarted()) {
            connection.start();
        }
    }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message