users@glassfish.java.net

JMS Connection Leak

From: <glassfish_at_javadesktop.org>
Date: Thu, 07 Oct 2010 11:00:47 PDT

We have the following method that is leaking JMS connections. Our timeout is currently set to 180 seconds. I'd like to hear what are some likely candidates here. As far as we can tell, we have a process that's taking longer than 180 seconds and the connection is getting reaped. Any ideas

[code]
public void submit(int reportID) {
        try {
            Context ctx = LocalConnection.getInitialContext();
            ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup("jms/ConnectionFactory");
            Destination destination = (Destination) ctx.lookup("jms/send_report_watch_emails");
            try {
                Connection connection = connectionFactory.createConnection();
                try {
                    Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
                    try {
                        MessageProducer producer = session.createProducer(destination);
                        TextMessage message = session.createTextMessage();
                        message.setText(Integer.toString(reportID));
                        producer.send(message);
                    } finally {
                        session.close();
                    }
                } finally {
                    connection.close();
                }
            } catch (JMSException ex) {
                // don't raise the exception because it will cause a rollback
                Logger.getLogger(ReportWatchSubmitterBean.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (NamingException ex) {
            // don't raise the exception because it will cause a rollback
            Logger.getLogger(ReportWatchSubmitterBean.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
[/code]
[Message sent by forum member 'preston001']

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