users@glassfish.java.net

JMS connection

From: Danilo Levantesi <danilo.levantesi_at_gmail.com>
Date: Fri, 19 Jun 2009 18:51:16 +0200

Hi to all.

I'm experiencing a weird behaviour; my app sends many JMS messages on a topic
(via SLSB), but sometimes, under heavy load, the following exception occurs
(in the following code excerpt it is generated by the
connectionFactory.createTopicConnection() call):

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.

The application is composed by one topic publisher and two topic subscribers;
the publisher uses the following code:


TopicConnection connection = null;
TopicSession session = null;
TopicPublisher publisher = null;

try {
    connection = connectionFactory.createTopicConnection(); // <= Exception
    session = connection.createTopicSession(false, session.AUTO_ACKNOWLEDGE);
    publisher = session.createPublisher(topic);

    Message msg = session.createTextMessage("something");
    publisher.publish(msg);
} catch (Throwable t) {
    // Exception handling here
    // ....
} finally {

         if (publisher!=null)
             try { publisher.close(); } catch (Throwable t) {}

         if (session != null)
             try { session.close(); } catch (Throwable t) {}

         if (connection == null)
             try { connection.close(); } catch (Throwable t) {}
    }
}


How can I debug why the connections are not closed (or at least it seems to
me), even if I call the connection.close() method?

Many thanks in advance
Danilo