users@glassfish.java.net

JMS running out of connections

From: <glassfish_at_javadesktop.org>
Date: Mon, 25 Oct 2010 08:03:20 PDT

Hello,
I am having a problem with my jms queue that it is running out of connections. The error I am getting is this


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.createConnection(DirectConnectionFactory.java:262)
        at com.sun.messaging.jms.ra.DirectConnectionFactory.createConnection(DirectConnectionFactory.java:241)
        at com.pts.core.creditor.CreditorSearchSubmitterBean.submit(CreditorSearchSubmitterBean.java:38)



Here is the submitter bean code.

[code]
import com.pts.core.ejb.LocalConnection;
import javax.ejb.Stateless;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.NamingException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Stateless(mappedName="CreditorLinkerSubmitterSession")
public class CreditorLinkingSubmitterBean implements CreditorLinkingSubmitterRemote {
    private static final Logger logger = LoggerFactory.getLogger(CreditorLinkingSubmitterBean.class);
    public void submit(int reportItemID) {
        logger.debug("Attempting to submit message to jms/CreditorLinkingQueue");
        try {
            Context ctx = LocalConnection.getInitialContext();
            ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup("jms/ConnectionFactory");
            Destination destination = (Destination) ctx.lookup("jms/CreditorLinkingQueue");
            try {
                Connection connection = connectionFactory.createConnection();
                try {
                    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                    MessageProducer producer = null;
                    try {
                        producer = session.createProducer(destination);
                        TextMessage message = session.createTextMessage();
                        message.setText(Integer.toString(reportItemID));
                        producer.send(message);
                        logger.debug("Done Submitting jms/CreditorLinkingQueue");
                    } finally {
                        if(producer != null)
                            producer.close();

                        if(session != null)
                            session.close();
                    }
                } finally {
                    if(connection != null)
                        connection.close();
                }
            } catch (JMSException ex) {
                logger.error("Error Submitting to Creditor Linking Queue.",ex);
            }
        } catch (NamingException ex) {
            logger.error("Error Looking up JMS queue.",ex);
        }
        logger.debug("Really Done Submitting jms/CreditorLinkingQueue");

    }

    
 
}
[/code]

The version of Glassfish we are running is [b]"Sun GlassFish Enterprise Server v2.1.1 Patch03 ((v2.1 Patch09)(9.1_02 Patch15)) (build b01-p03)"[/b]
[Message sent by forum member 'epicofchaos']

http://forums.java.net/jive/thread.jspa?messageID=486161