Thursday, November 26, 2009

Which JMS Connection Factory shall I use?

unless a Connection Factory has been explicitely specified for a Queue, WebLogic will use a default connection factory named:

JMS_FACTORY="weblogic.jms.ConnectionFactory"

this will be in the JNDI_TREE for you to use:

Here is the (crazy and cumbersome) code:

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL,"t3://localhost:7001");
InitialContext ctx = new InitialContext(env);


QueueConnectionFactory   qConFactory = (QueueConnectionFactory)ctx.lookup("weblogic.jms.ConnectionFactory");
QueueConnection     qCon        = qConFactory.createQueueConnection();
QueueSession     qSession    = qCon.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
Queue       queue2       = (Queue)ctx.lookup(jms_queue);
QueueSender        qSender     = qSession.createSender(queue2);
TextMessage      msg         = qSession.createTextMessage();

qCon.start();

No comments: