activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <tabish...@gmail.com>
Subject Re: Questions about PooledConnectionFactory in AMQ 5.8
Date Tue, 19 Nov 2013 16:20:28 GMT
On 11/19/2013 10:52 AM, Jose MarĂ­a Zaragoza wrote:
> Hello:
>
> I'm using AMQ 5.8 and I've got some questions about PooledConnectionFactory:
>
>
> This is my testing configuration , running in JVM 6
>
> // ConnectionFactory
> ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory("failover:(tcp://broker1:61616?connectionTimeout=3000,tcp://broker2:61616?connectionTimeout=3000)?timeout=5000&startupMaxReconnectAttempts=1&maxReconnectAttempts=1&randomize=false&priorityBackup=false");
>
> //PooledConnectionFactory  ( size 1 )
> PooledConnectionFactory pooledConnectionFactory = new
> PooledConnectionFactory(connectionFactory);
> pooledConnectionFactory.setMaxConnections(1);
>
> Connection connection1 = pooledConnectionFactory.createConnection();
> Connection connection2 = pooledConnectionFactory.createConnection();
>
>
> 1)
>
> I've checked that connection1 != connection2  , i.e., they are
> different instances  , does't it make any sense ?
> Pool size is 1 , so I would wait that they were the same instance
>
>
> 2)
>
> I've checked that if connection1 is started ( connection1.start() ) ,
> connection2 doesn't require to execute connection2.start()
> So, I guess that connection1  and connection2 share something but they
> aren't "the same thing "
>
> 3)
>
> I've checked that connection1.stop() or connection2.stop() ( i guess
> that over any PooledConnection ) don't do anything
> I wonder why , though it's not a problem for me
>
>
> 4)
>
> I've checked that connection1.close() only has effect on consumers
> created on connection1 , and connection2.close() only has effect on
> consumers created on connection2. So, it seems they are different
> things.
> But if I has got only one connection in pool, how I can close *that*
> connection ? ( I don't want to close all of then with clear() method
> on PooledConnectionFactory, but I want to close a single connection )
>
>
> Thanks and regards
>
The PooledConnectionFactory returns object of type PooledConnection 
which wrap the underlying connections managed by the pool.  If you want 
to check if they are using the same Connection instance then you can 
cast to PooledConnection and call the getConnection method to check that 
these are the same instance in your case.

-- 
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.fusesource.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/


Mime
View raw message