activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Mielke <tors...@fusesource.com>
Subject Re: PooledConnectionFactory per session
Date Mon, 02 Apr 2012 07:26:26 GMT
Hello,

Check the javadoc of PooledConnectionFactory [1]. 
The class description mentions that this ConnectionFactory also pools sessions and MessageProducers.


Your approach looks correct to me. Every call to createConnection() and createSession() will
reuse these objects from the pool (after an initial ramp up period where these resources get
created). 

Make sure to close all resources properly in order to return them back to the pool.


[1] http://activemq.apache.org/maven/5.5.0/activemq-pool/apidocs/org/apache/activemq/pool/PooledConnectionFactory.html


Hope this helps,


Torsten Mielke
torsten@fusesource.com
tmielke@blogspot.com





On Mar 30, 2012, at 8:47 PM, rdiasfreitas wrote:

> We have the following use case:
> 
> 1) We are using Apache + Coldfusion as application server;
> 2) Many logged users may need to send a message to the Coldfusion Server,
> and the Coldfusion Server, after doing some validations, will format a
> MapMessage and put on the Queue;
> 3) Coldfusion is serving up to 100 simultaneous requests, under heavy load.
> 4) We need to have the lowest latency in this process.
> 
> At this moment, for each message we are opening a new connection, creating a
> session, a producer, sending the message, closing the session, closing the
> connection.
> 
> Of course this is not the proper way to do this.
> 
> I was studying the PooledConnectionFactory, and I need some clarification
> about the proper way to make this: 
> 
> PooledConnectionFactory pool = new PooledConnectionFactory(
> connectionFactory);
> pool.setMaxConnections(10);
> pool.setMaxActive(5); // 10*5 = 10 threads on the server, with 5
> simultaneous sessions
> pool.start();
> 
> The variable pool is made static, and it's a server variable. Access to it
> is synchronized.
> 
> Everytime I need to send a message, I call:
> 
> con = pool.createConnection();
> Session session = con.createSession( xxxx );
> MessageProducer producer =
> session.createProducer(session.createQueue("QUEUE_MESSAGES");
> MapMessage message = session.createMapMessage();
> message.setString('aaaa', 'bbbbb');
> producer.send(message);
> session.close();
> 
> Please, help me with:
> 
> 1) Is this approach correct?
> 2) I could not find any place to have pooled SESSIONS instead of
> CONNECTIONS. This would free us from the overhead of creating a session,
> producer, etc... 
> 
> Any comments will be highly appreciated.
> 
> Thanks,
> 
> 
> 
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/PooledConnectionFactory-per-session-tp4520006p4520006.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.





Mime
View raw message