dev@glassfish.java.net

Re[2]: JMS error: Cannot allocate more connections.

From: Dmitry Mozheyko <mozheyko_d_at_mail.ru>
Date: Tue, 01 Aug 2006 17:32:57 +0400

-----Original Message-----
From: Cheng Fang <Cheng.Fang_at_Sun.COM>
To: dev_at_glassfish.dev.java.net
Date: Tue, 01 Aug 2006 09:32:28 -0400
Subject: Re: JMS error: Cannot allocate more connections.

>
> Because you release JMS resources in @PreRemove method, you have no
> control when they are released. @PreRemove methods are invoked when
> beans are to be destroyed, maybe long after it has been returned to the
> pool. In you app, every bean instance, even when they are in pool,
> holds an open connection. Try releasing resources from within your
> busines methods.
>
> Cheng

Thank you.
So is your way effective?
What stateless-session-EJB methods i can use for safe initialization and finalization my resources?

>
>
>
>
> Dmitry Mozheyko wrote:
>
> >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?
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> >For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>