users@glassfish.java.net

Re: Failed to obtain/create connection from connection pool

From: <glassfish_at_javadesktop.org>
Date: Tue, 20 Oct 2009 05:20:53 PDT

Hello prrm,

your connection pool of producers exceeds.

Modify your code:

Make your test ejb stateful.

Add two methods: init and close
{code}
public void init() {
  qConn = jmsLocator.getQueueConnection();
  session = qConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
  producer = session.createProducer(jmsLocator.getMessageQueue());
  msg = session.createObjectMessage();
  msg.setObject(message);
}

public void close() {
  qConn.close();
  session.close();
}
{code}

I don't take care about exception handling in this demo code.

Modify your enqueue method:

{code}
public void enqueue(MessageObj message) {
  msg = session.createObjectMessage();
  msg.setObject(message);
  producer.send(msg);
}
{code}

And your client:
{code}
testEjbBean.init();
for(int i=0;i<120;i++){
MessageObj msobj=new MessageObj(rr,0);
testEjbBean.enqueue(msobjj);
}
testEjbBean.close();
{code}

… should run now.

Greetings from Hamburg,

Andreas


… ahh, and by the way, have a look at interceptors to avoid your logging code on starting and ending a method.
[Message sent by forum member 'angerhard' (java.net_at_servicepack7.de)]

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