activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Rosenberg (JIRA)" <>
Subject [jira] Created: (AMQ-1581) PooledConnections don't initialize correctly when broker not available (causes problems with Failover)
Date Wed, 06 Feb 2008 16:52:36 GMT
PooledConnections don't initialize correctly when broker not available (causes problems with

                 Key: AMQ-1581
             Project: ActiveMQ
          Issue Type: Bug
          Components: Transport
         Environment: 5.1-SNAPSHOT
            Reporter: Jason Rosenberg

In working with PooledConnections, I've found that there is a timing race condition that can
occur on the initialization of new ConnectionPool objects.  The ConnectionPool object adds
a custom TransportListener, which implements the onException method, in order to be informed
when the transport has failed, so that it can properly execute its 'expiredCheck' method,
and allow the PooledConnectionFactory to remove it from the ConnectionPool....

In the case of using an underlying FailoverTransport, which sets the maxReconnectAttempts
to something small, such as "2", then it's possible that the FailoverTransport could fail
prior to the ConnectionPool object completing it's own initialization, and thus prior to it's
adding it's TransportListener to the connection.  I would expect there are other transports
that could also fail immediately and have the same behavior.

This scenario is readily reproducible in the case where the client is started up with no broker

I've found a solution by adding a simple check after the call to addTransportListener, to
check for any prior transport failed, by calling 'connection.isTransportFailed()', and setting
the 'hasFailed' flag if true.  This will update the flag for those cases that did not successfully
add the transport listener prior to that initial failure.

Without this fix, the ConnectionPool is unusable, in that the underlying connection will never
be evicted to from the PooledConnectionFactory....This is especially pronounced if the idleTimeout
is set to 0, and it never recovers.


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

View raw message