PooledConnectionFactory: createConnection results in log entry "Successfully connected to ..."

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

PooledConnectionFactory: createConnection results in log entry "Successfully connected to ..."

jochenw
Hello,

I'm just starting using the PooledConnectionFactory. Before calling the start() method, the idleTimeout (30000 ms), the maxConnections (10) and the maximumActiveSessionPerConnection (500) are set.

I would have expected that on startup, 10 connections are opened to the broker (tcp://0.0.0.0:61616), and these 10 connections are used when I start sending messages. However, on each pooledConnectionFactory.createConnection(), there is another entry in the log "Successfully connected to tcp://0.0.0.0:61616".

It this log entry also appearing when creating a connection to a connection pool although no new broker connection is opened? Or does this mean that a new connection is set up to the broker - indicating that I did something wrong when using the connection pool?

Regards,
Jochen
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PooledConnectionFactory: createConnection results in log entry "Successfully connected to ..."

MichaelAndrePearce
The PooledConnectionFactory just pools created connections so that they can be reused. The connections are created as you've noted on createConnection.

A really good description of its behaviour is written in doc see here:
http://activemq.apache.org/maven/5.15.0/apidocs/org/apache/activemq/jms/pool/PooledConnectionFactory.html


Cheers,
Mike.

Sent from my iPhone

> On 3 Jul 2017, at 07:17, jochenw <[hidden email]> wrote:
>
> Hello,
>
> I'm just starting using the PooledConnectionFactory. Before calling the
> start() method, the idleTimeout (30000 ms), the maxConnections (10) and the
> maximumActiveSessionPerConnection (500) are set.
>
> I would have expected that on startup, 10 connections are opened to the
> broker (tcp://0.0.0.0:61616), and these 10 connections are used when I start
> sending messages. However, on each
> pooledConnectionFactory.createConnection(), there is another entry in the
> log "Successfully connected to tcp://0.0.0.0:61616".
>
> It this log entry also appearing when creating a connection to a connection
> pool although no new broker connection is opened? Or does this mean that a
> new connection is set up to the broker - indicating that I did something
> wrong when using the connection pool?
>
> Regards,
> Jochen
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/PooledConnectionFactory-createConnection-results-in-log-entry-Successfully-connected-to-tp4728188.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PooledConnectionFactory: createConnection results in log entry "Successfully connected to ..."

jochenw
Hi Mike,

thanks for the answer. Of course I have checked this . It says: "A JMS provider which pools Connection, Session and MessageProducer instances so it can be used with tools like Camel and Spring's JmsTemplate and MessagListenerContainer. Connections, sessions and producers are returned to a pool after use so that they can be reused later without having to undergo the cost of creating them again."

However, I can see the log entries "Successfully connected to tcp://0.0.0.0:61616" all the time - I would have expected that when the first connections have been created, they are reused from the pool, and there will be no more messages in the log file that a connection to the broker has been made.

Cheers,
Jochen
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PooledConnectionFactory: createConnection results in log entry "Successfully connected to ..."

MichaelAndrePearce
Hi Jochen

Could I suggest maybe looking at the test cases how they're using it and see what maybe different in your code?

In particular look at testConnectionsArePooled

https://github.com/apache/activemq/blob/master/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java

Cheers
Mike



Sent from my iPhone

> On 4 Jul 2017, at 06:17, jochenw <[hidden email]> wrote:
>
> Hi Mike,
>
> thanks for the answer. Of course I have checked this . It says: "A JMS
> provider which pools Connection, Session and MessageProducer instances so it
> can be used with tools like Camel and Spring's JmsTemplate and
> MessagListenerContainer. Connections, sessions and producers are returned to
> a pool after use so that they can be reused later without having to undergo
> the cost of creating them again."
>
> However, I can see the log entries "Successfully connected to
> tcp://0.0.0.0:61616" all the time - I would have expected that when the
> first connections have been created, they are reused from the pool, and
> there will be no more messages in the log file that a connection to the
> broker has been made.
>
> Cheers,
> Jochen
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/PooledConnectionFactory-createConnection-results-in-log-entry-Successfully-connected-to-tp4728188p4728195.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PooledConnectionFactory: createConnection results in log entry "Successfully connected to ..."

jochenw
Hi Mike,

good idea. I still have to do some testing, but on a first glance, I saw that in the JUnit test, they never close a created connection.

I thought that after getting a connection from the PooledConnectionFactory with connection = pooledConnectionFactory.createConnection() and having finished the work (message sent), you have to call connection.close() to give the connection back to the connection pool. Is that correct? Or does a connection.close() close the connection to the broker? That would explain why on each createConnection(), there is a new entry in the log that a connection to the broker has been made, since connections are never re-used. In this case it would be correct to only close the session, but leave the connection open.

Cheers,
Jochen
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PooledConnectionFactory: createConnection results in log entry "Successfully connected to ..."

jochenw
Hi,

sorry, but the issue was a different one. It was my misunderstanding of the idleTimeout property. Is doesn't timeout a connection which is used from the pool, but the connection which the pool opens to the broker. My settings were such that the timeout was too short for the connection pool to cycle through all connections before some of the first connections timed out. So some of the connections from the pool were closed, and of course re-opened when it was their turn again. As soon as the message frequency is higher, or I set the timeout to a higher value, the re-connections to the broker no longer show up in the log file.

Regards,
Jochen
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PooledConnectionFactory: createConnection results in log entry "Successfully connected to ..."

MichaelAndrePearce
Hi Jochen,

Excellent news, glad you have found and resolved your issue.

Cheers,
Mike

Sent from my iPhone

> On 7 Jul 2017, at 16:00, jochenw <[hidden email]> wrote:
>
> Hi,
>
> sorry, but the issue was a different one. It was my misunderstanding of the
> idleTimeout property. Is doesn't timeout a connection which is used from the
> pool, but the connection which the pool opens to the broker. My settings
> were such that the timeout was too short for the connection pool to cycle
> through all connections before some of the first connections timed out. So
> some of the connections from the pool were closed, and of course re-opened
> when it was their turn again. As soon as the message frequency is higher, or
> I set the timeout to a higher value, the re-connections to the broker no
> longer show up in the log file.
>
> Regards,
> Jochen
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/PooledConnectionFactory-createConnection-results-in-log-entry-Successfully-connected-to-tp4728188p4728324.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Loading...