users@glassfish.java.net

RE: Failed to obtain/create connection from connection pool

From: Sigal Shaharabani <Sigal.Shaharabani_at_Teledata-Networks.com>
Date: Tue, 20 Oct 2009 17:15:44 +0200

Try using the DataSourceConnectionPool instead of ConnectionPool
This way you're reusing the connections, it helped me a lot! (now I only
have problems with cursors)

P please consider the environment - do you really need to print this
email?
-----Original Message-----
From: glassfish_at_javadesktop.org [mailto:glassfish_at_javadesktop.org]
Sent: Tuesday, October 20, 2009 2:11 AM
To: users_at_glassfish.dev.java.net
Subject: Failed to obtain/create connection from connection pool

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(Dir
ectConnectionFactory.java:574)
        at
com.sun.messaging.jms.ra.DirectConnectionFactory.createQueueConnection(D
irectConnectionFactory.java:320)
        at
com.sun.messaging.jms.ra.DirectConnectionFactory.createQueueConnection(D
irectConnectionFactory.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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net