dev@glassfish.java.net

JMS error: Cannot allocate more connections.

From: Dmitry Mozheyko <mozheyko_d_at_mail.ru>
Date: Tue, 01 Aug 2006 09:11:18 +0400

Hello all.

I need to use ejbTimers for sending jms messages. This is a parts of my session bean-code with @Timeout method:

@Stateless
public class CServiceTimerBean extends CBean implements CServiceTimerLocal {
    ...
    @Resource
    TimerService timerService;
    
    @Resource(mappedName="jms/ServiceDemandConnectionFactory")
    private ConnectionFactory connectionFactory;
    
    @Resource(mappedName="jms/ServiceDemandQueue")
    private Queue emailQueue;
    
    private Connection connection = null;
    
    private Session session = null;
    
    private MessageProducer messageProducer = null;
    
    @PostConstruct // Allocating JMS resources
    public void ejbPostConsruct() {
        
        try {
            
            connection = connectionFactory.createConnection();
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            messageProducer = session.createProducer(emailQueue);
            
        } catch (JMSException e) {
            
            e.printStackTrace();
            
        }
        
    }
    
    @PostRemove // Release JMS resources
    public void ejbPostRemove() {
        
        try {
            
            messageProducer.close();
            session.close();
            connection.close();
            
        } catch (JMSException e) {
            
            e.printStackTrace();
            
        }
        
    }
    ...
    @Timeout
    public void timeout(Timer timer) {
        ...
        try {
            messageProducer.send(message);
        }
        ...
    }
...

After some count of message(near of JMS-pool default size) i receive this error:

[#|2006-08-01T04:02:05.048+0400|WARNING|sun-appserver-pe9.1|javax.enterprise.resource.resourceadapter|_ThreadID=46;_ThreadName=p: thread-pool-1; w: 111;In-use connections equal max-pool-size and expired max-wait-time. Cannot allocate more connections.;_RequestID=33b5a5fe-b4af-4931-80f6-cb7f30a8231e;|RAR5117 : Failed to obtain/create connection. Reason : In-use connections equal max-pool-size and expired max-wait-time. Cannot allocate more connections.|#]

[#|2006-08-01T04:02:05.049+0400|WARNING|sun-appserver-pe9.1|javax.enterprise.system.stream.err|_ThreadID=46;_ThreadName=p: thread-pool-1; w: 111;_RequestID=33b5a5fe-b4af-4931-80f6-cb7f30a8231e;|
com.sun.messaging.jms.JMSException: MQRA:CFA: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.ConnectionFactoryAdapter._createConnection(ConnectionFactoryAdapter.java:153)
        at com.sun.messaging.jms.ra.ConnectionFactoryAdapter.createConnection(ConnectionFactoryAdapter.java:136)
        at com.sun.messaging.jms.ra.ConnectionFactoryAdapter.createConnection(ConnectionFactoryAdapter.java:118)
        at ejb.session.CServiceTimerBean.ejbPostConsruct(Unknown Source)

Why my JMS resources NOT releasing?