activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anuj Khandelwal (JIRA)" <>
Subject [jira] [Commented] (AMQ-5357) Race conditions in ActiveMQ Connection Pooling
Date Wed, 24 Sep 2014 06:57:34 GMT


Anuj Khandelwal commented on AMQ-5357:

Hi Tim,

I have tried to reproduce. It's not the exact test case but kind of similar problem. 

1. I have my own local plugin "ActiveMQLoggingPlugin extends BrokerPluginSupport" and override
"removeConnections" and "removeSession" functions.
2. I returned from the functions without passing it to super class for example: 
    public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable
error) throws Exception
        if (info.toString() != "hello") {
            return; // It's a hack so that it always return from here. 
        super.removeConnection(context, info, error);

3. Now when I run the client application(consumers) which is using pooledConnectionFactory
with maxConnection=5. it is creating 5 different connections using different client ids. Each
listeners is a durable subscriber and I am setting different client id for each of them (It
is using the configuration mentioned in previous comment)

4. It is able to connect and work properly. Now I stop the client application. I can see that
connections are gone and applciation is stopped. I checked that broker is not connecting to
any client now. 

5 Now when I start the client application. I get the invalidclientIDexception by saying that
this client is already connected to the broker. 
I think since broker is not closing the connection, it keeps the client id associated with
it and does not clear the connection state. and when next time application starts, it says
that client is already connected even if no client is actually connected to the broker. 


> Race conditions in ActiveMQ Connection Pooling
> ----------------------------------------------
>                 Key: AMQ-5357
>                 URL:
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: activemq-pool, Broker
>    Affects Versions: 5.10.0
>            Reporter: Anuj Khandelwal
> Hi,
> Broker version : 5.10.0
> Problem : 
> I am using ActiveMQv5.10.0 broker in my setup. In my broker I am facing a weird problem
where a durable subscriber is not able to connect to the broker because of stale subscription
shown by the broker with the same client id. Please note that this issue is not reproducible,
I tried but not able to reproduce. It happens sometimes. 
> Details: 
> In my application I am creating 3 durable subscriptions on different topics. I am using
PooledConnectionFactory with maxConnection=3 to create connections for each listener. I am
using separate Spring Default message listener container for creation of the each listener.

> Sometime when I start my client, I get below exception :  
> -----------
> listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful():907 ERROR]:
Could not refresh JMS Connection for destination 'topic://test.newPnlSpn' - retrying in 5000
ms. Cause: Broker: mqbrokerdev - Client: new_pnl_spn_test_client already connected from tcp://a.b.c.d:2338

> -----------
> But when I check connections from "a.b.c.d". I don;t see any connections from the IP.
Even on JConsole, it does not show any clients connecting to the same topic with this client_id.

> In some cases i observed that this is the IP address where my client was previously running.

> Because of this issue my current client which is running from some other IP address is
not able to connect to the broker. 
> I suspect that there is some race condition in ActiveMQ connection pooling. This is a
serious issue I am facing in my setup, My clients are not able to connect to the broker.
> When I face this issue :
> I tried to restart the broker by clearing out the persistent store, but this issue was
still there. It only got resolved when I changed the client ID of my listener. 
> Which means broker somewhere keeping stale connection state for this client id. As soon
as new client id comes, it start working properly and connecting to the broker.
> Detailed Error logs: 
> [20140915 16:23:14:964 IST (jmsContainer-6) org.springframework.jms.listener.DefaultMessageListenerContainer#handleListenerSetupFailure
666 ERROR] - Setup
>  of JMS message listener invoker failed - trying to recover 
> javax.jms.IllegalStateException: javax.jms.InvalidClientIDException: Broker: mqbrokerdev
- Client: new_pnl_spn_seed_client already connected from tcp://10
> *.*.*.*:3456
>         at org.apache.activemq.jms.pool.ConnectionPool.createSession(
>         at org.apache.activemq.jms.pool.PooledConnection.createSession(
>         at
>         at org.springframework.jms.listener.DefaultMessageListenerContainer.access$1000(
>         at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.initResourcesIfNecessary(DefaultMessageListenerCon
>         at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.jav
> a:869)
>         at org.springframework.jms.listener.DefaultMessageListenerContainer$
>         at
> Caused by: javax.jms.InvalidClientIDException: Broker: mqbrokerdev - Client: new_pnl_spn_seed_client
already connected from tcp://
>         at
>         at
>         at
>         at
>         at
>         at
>         at
>         at
>         at tools.jms.ActiveMQLoggingPlugin.addConnection(
>         at
>         at
>         at
>         at org.apache.activemq.command.ConnectionInfo.visit(
>         at
>         at$1.onCommand(
>         at org.apache.activemq.transport.MutexTransport.onCommand(
>         at org.apache.activemq.transport.WireFormatNegotiator.onCommand(
>         at org.apache.activemq.transport.AbstractInactivityMonitor.onCommand(
>         at org.apache.activemq.transport.TransportSupport.doConsume(
>         at org.apache.activemq.transport.tcp.TcpTransport.doRun(
>         at
>         ... 1 more
> Thanks,
> Anuj

This message was sent by Atlassian JIRA

View raw message