Below are the two approach which am using, Please help me to understand which one is better! Its a synchronous process.
Approach 1: (Not closing any connection object)
Created connectionfactory in below class and maintaining pool of that class
ConnectionPool.java (maintaining a pool of different producers with broker url)
private static Map<String, Producer> producers
public static ProducerPool getInstance() {
if(INSTANCE==null){
producers = Maps.newConcurrentMap();
INSTANCE= new ProducerPool();
}
return INSTANCE;
}
Producer.java (all the connection objects created here)
private ActiveMQConnection connection;
private ActiveMQSession session;
private MessageProducer producer;
return consumer.receive(5000);
So if 100 req comes also it will maintain only one connection , producer, session.
Approach 2:
(Closing all connection,session,producer per request and not a singleton)
Approach 3:
(Keeping only connection alive and closing session and producer per each req and recreate the same which is closed per request)
Which approach will suite for more performance? in request reply pattern maximum level which one(connection r session r producer) we can reuse? Had a glance at : (can anyone help with a example how to use it!)
PooledConnectionFactory
Please help which one should follow!
Aucun commentaire:
Enregistrer un commentaire