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:


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");
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();


No comments: