users@glassfish.java.net

_at_PostConstruct with Unckecked Expcetion

From: <glassfish_at_javadesktop.org>
Date: Mon, 24 Nov 2008 08:49:45 PST

I've got simple MDB component with @PostConstruct.

@MessageDriven(mappedName = "incoming")
public class SMSSender implements MessageListener
{
        private Connection connection;
        private Destination outgoing;

        @PostConstruct
        public void onConstruct()
        {
                InitialContext ctx;
                try {
                        ctx = new InitialContext();
                        ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup("outgoing_factory");
                        connection = connectionFactory.createConnection();
                        outgoing = (Destination) ctx.lookup("outgoing");
                } catch (Exception e) {
                        throw new RuntimeException("Cannot find needed jms resources",e);
                }

        }

        @PreDestroy
        public void onDestroy()
        {
                if (connection != null) {
                        try {
                                connection.close();
                        } catch (JMSException e) {
                                log.error("Cannot close jms connection", e);
                        }
                }
        }

        @SuppressWarnings("unchecked")
        public void onMessage(Message message)
        {
                // save in DB for example
               // and send in jms queue "outgoing"
        }
}

But sometimes i've got exception. "Cannot allocate more jms connections......etc"
Is there are some way to pool jms connections for "outgoing" or how i must configure outgoing_factory in case of growing mdbs (more applications will be deployed)?
[Message sent by forum member 'dernasherbrezon' (dernasherbrezon)]

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