You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Dejan Bosanac (JIRA)" <ji...@apache.org> on 2010/12/02 14:11:23 UTC

[jira] Updated: (AMQ-2326) Using connection pool, ActiveMQConnection is not started if an error occur during first attempt to start the connection.

     [ https://issues.apache.org/jira/browse/AMQ-2326?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dejan Bosanac updated AMQ-2326:
-------------------------------

    Fix Version/s:     (was: 5.4.2)
                   5.5.0

> 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/jira/browse/AMQ-2326
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.2.0
>            Reporter: Mathieu Baril
>             Fix For: 5.5.0
>
>
> 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.