FileDocCategorySizeDatePackage
JmsClient_1.javaAPI DocExample1940Sun Mar 17 16:56:20 GMT 2002com.titan.clients

JmsClient_1

public class JmsClient_1 extends Object implements javax.jms.MessageListener

Fields Summary
Constructors Summary
public JmsClient_1()

        
    Context jndiContext = getInitialContext();
    
    TopicConnectionFactory factory = (TopicConnectionFactory)
     //   jndiContext.lookup("java:comp/env/jms/TopicFactory");
    jndiContext.lookup("titan-TopicFactory");

   // Topic topic = (Topic) jndiContext.lookup("java:comp/env/jms/TicketTopic");
     Topic topic = (Topic) jndiContext.lookup("titan-TicketTopic");
    TopicConnection connect = factory.createTopicConnection();

    TopicSession session = 
        connect.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); 

    TopicSubscriber subscriber = session.createSubscriber(topic);

    subscriber.setMessageListener(this);
    
    System.out.println("Listening for messages on titan-TicketTopic...");
    connect.start();
Methods Summary
public static javax.naming.ContextgetInitialContext()

		return new InitialContext();
    
public static voidmain(java.lang.String[] args)

        
        new JmsClient_1();
        
        while(true) { Thread.sleep(1000); }
        
    
public voidonMessage(javax.jms.Message message)

    try {
        TextMessage textMsg = (TextMessage)message;
        String text = textMsg.getText();
        System.out.println("\n RESERVATION RECEIVED:\n"+text);
    } catch(JMSException jmsE) {
        jmsE.printStackTrace();
    }