activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdiasfreitas <freitas.rodr...@gmail.com>
Subject PooledConnectionFactory per session
Date Fri, 30 Mar 2012 18:47:29 GMT
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