Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JMS and client application

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, here is my code ..

public class JMSProducer
public static void main(String[] args)
Context ctx = null;
TopicConnectionFactory cf = null;
TopicConnection con = null;
Topictopic= null;
TopicSessionses = null;

Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL, "localhost:1099");

ctx = new InitialContext(properties);
} catch (NamingException e) {
System.out.println("Could not create JNDI API context : "+ e.toString());

try {
cf = (TopicConnectionFactory) ctx.lookup("jms/TopicConnectionFactory");
topic= (Topic) ctx.lookup("jms/Topic");
} catch (NamingException e1) {
System.out.println("JNDI API lookup failed : "+ e1.toString());

try {
con = cf.createTopicConnection();
ses = con.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
TopicPublisher pub = ses.createPublisher(topic);
TextMessage msg = ses.createTextMessage();

} catch (JMSException e2) {

In these client application, i lookup for the jndi names of Conenction factory and Destination(jms/TopicConnectionFactory, jms/topic). My question is where to configure these jndi name. In case of servlet/jsp, we configure jndi in web.xml and server specific xml files. But in case of client application, where u have to specify the resouurces...

urgent pls,
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic