• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Resuse JMS Connection factory and jms Connection

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created single MDB for processing all messages but for every messages it intialises all JMS resources every time.
I want to reuse all JMS resources .

my Existing code is

public InitialContext getInitialContext()
throws NamingException, Exception
{
String location = CLASS_NAME + ".getInitialContext()";
log.info("Entering : " + location);

String initialCtx = PMTCProperties.getProperty("FAS_INI_CTC_FACT");
String providerURL = PMTCProperties.getProperty("FAS_URL");

prop.put(Context.INITIAL_CONTEXT_FACTORY, initialCtx);
prop.put(Context.PROVIDER_URL, providerURL);
Context ctx = new InitialContext(prop);
Hashtable env = new Hashtable();



env.put(Context.INITIAL_CONTEXT_FACTORY, initialCtx);
log.info("Exiting :" + location);
return new InitialContext(env);
}


/**
* Creates all the necessary objects for sending messages to a JMS queue.
*
* @param ctxJNDI initial context
* @paramqueueNamename of queue
* @exception NamingException if operation cannot be performed
* @exception JMSException if JMS fails to initialize due to internal error
*/
public void init(Context ctx, String queueName)
throws NamingException, JMSException ,Exception
{
String location = CLASS_NAME + ".init()";
log.info("Entering : " + location);
log.debug("PMTCProperties.getProperty(JMS_FACTORY)==="+PMTCProperties.getProperty("JMS_FACTORY"));
log.debug("PMTCProperties.getProperty(JMS_FACTORY)==="+PMTCProperties.getProperty("FAS_JMS_FACTORY"));
//qconFactory = (QueueConnectionFactory) ctx.lookup(PMTCProperties.getProperty("JMS_FACTORY"));
qconFactory = (QueueConnectionFactory) ctx.lookup(PMTCProperties.getProperty("FAS_JMS_FACTORY"));
qcon = qconFactory.createQueueConnection();
qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
queuereceive = (Queue) ctx.lookup(queueName);
qsender = qsession.createSender(queuereceive);
msg = qsession.createTextMessage();
qcon.start();
log.info("Exiting :" + location);
}



Could some one guide me how to avoid this?

Thanks in advance

Manish
 
You don't like waffles? Well, do you like this tiny ad?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic