Problem Scenario
I'm creating dynamic connections for sending of SMS using the javax.jms.QueueConnectionFactory. Upon reaching the max. no. of connections, the following error is popping up.
I am confused if:
1. I should increase the number of connections. If yes, what is a safe limit without effecting performance
2. Some cleaning / closing the connection needs to be done which I have ommited.
Error
RAR5117 : Failed to obtain/create connection from connection pool [ jms/RideHandlerQueueFactory ]. Reason : In-use connections equal max-pool-size and expired max-wait-time. Cannot allocate more connections.
The log message is null.
com.sun.messaging.jms.JMSException: MQRA:DCF:allocation failure:createConnection:Error in allocating a connection. Cause: In-use connections equal max-pool-size and expired max-wait-time. Cannot allocate more connections.
at com.sun.messaging.jms.ra.DirectConnectionFactory._allocateConnection(DirectConnectionFactory.java:574)
at com.sun.messaging.jms.ra.DirectConnectionFactory.createQueueConnection(DirectConnectionFactory.java:320)
at com.sun.messaging.jms.ra.DirectConnectionFactory.createQueueConnection(DirectConnectionFactory.java:297)
Code
Opening 120 connections
for(int i=0;i<120;i++){
MessageObj msobjj=new MessageObj(rr,0);
testEjbBean.enqueue(msobjj);
}
The enqueue method in TestEJBBean to send messages
public void enqueue(MessageObj message)
{
this.logger=org.apache.log4j.Logger.getLogger(this.getClass().getName());
logger.debug("Entered into enqueue method");
logger.info("Entered into SMS queue");
try{
qConn = jmsLocator.getQueueConnection();
session = qConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
msg = session.createObjectMessage();
msg.setObject(message);
session.createProducer(jmsLocator.getMessageQueue()).send(msg);
}catch(Exception ex){
Logger.getLogger(TestEjbBean.class.getName()).log(Level.SEVERE, null, ex);
logger.error("EXCEPTION RAISED REFER SERVER.LOG");
try {
qConn.close();
session.close();
} catch (JMSException ex1) {
Logger.getLogger(TestEjbBean.class.getName()).log(Level.SEVERE, null, ex1);
}
}
logger.debug("Exiting MessageObj method");
logger.info("Exiting into SMS queue");
}
Glassfish Server Configuration
Initial and maximum pool size 8
Max pool size 100
Pool Resize quantity 2
Idle Timeout 300
Max wait time 60000
Glassfish version : Sun GlassFish Enterprise Server v2.1 (9.1.1) (build b60e-fcs)
[Message sent by forum member 'prrm' (charan.1986_at_gmail.com)]
http://forums.java.net/jive/thread.jspa?messageID=368547