Problem in getting ServerSessionPoolFactory
uzubair Mar 13, 2003 2:06 AM
Hi,
I am facing exception javax.naming.NameNotFoundException: org.jboss.jms.asf.StdServerSessionPoolFactory not bound
on line stdServerSessionPoolFactory = (StdServerSessionPoolFactory) ctx.lookup("java:/StdJMSPool");
Does anybody know, why is it happening. I am not using MDB.
package examples.jms.sessionpool;
import java.io.*;
import java.util.*;
import javax.naming.*;
import javax.jms.*;
import org.jboss.jms.asf.ServerSessionPoolFactory;
import org.jboss.jms.asf.StdServerSessionPoolFactory;
public class QueuePool
{
private final static String JNDI_FACTORY="org.jnp.interfaces.NamingContextFactory";
private final static String JMS_FACTORY="ConnectionFactory";
private final static String QUEUE="testQueue";
private final static String SESSION_POOL_FACTORY="org.jboss.jms.asf.StdServerSessionPoolFactory";
private final static String MESSAGE_LISTENER="examples.jms.sessionpool.MsgListener";
private QueueConnectionFactory qconFactory;
private QueueConnection qcon;
private QueueSession qsession;
private QueueSender qsender;
private Queue queue;
private TextMessage msg;
private ServerSessionPoolFactory sessionPoolFactory;
private StdServerSessionPoolFactory stdServerSessionPoolFactory;
private ServerSessionPool sessionPool;
private ConnectionConsumer consumer;
public void init(Context ctx, String queueName)
throws NamingException, JMSException, Exception
{
qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);
qcon = qconFactory.createQueueConnection();
qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
try {
queue = (Queue) ctx.lookup(queueName);
} catch (NamingException ne) {
queue = qsession.createQueue(queueName);
ctx.bind(queueName, queue);
}
qsender = qsession.createSender(queue);
msg = qsession.createTextMessage();
qcon.start();
stdServerSessionPoolFactory = (StdServerSessionPoolFactory) ctx.lookup("java:/StdJMSPool");
sessionPool = stdServerSessionPoolFactory.getServerSessionPool(qcon, 5, false,
Session.AUTO_ACKNOWLEDGE, true,
(MessageListener)((Class.forName("examples.jms.sessionpool.MsgListener").newInstance())));
consumer = qcon.createConnectionConsumer(queue, "TRUE", sessionPool, 10);
}
public static void main(String[] args)
throws Exception
{
InitialContext ic = getInitialContext(args[0]);
QueuePool qp = new QueuePool();
qp.init(ic, QUEUE);
System.out.println("JMS Session Pool Established");
qp.close();
}
protected static InitialContext getInitialContext(String url)
throws NamingException
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
env.put(Context.PROVIDER_URL, url);
return new InitialContext(env);
}
}
Regards
Umar