FileDocCategorySizeDatePackage
JmsClient_TicketConsumer.javaAPI DocExample2174Sun Mar 17 22:53:24 GMT 2002com.titan.clients

JmsClient_TicketConsumer

public class JmsClient_TicketConsumer extends Object implements javax.jms.MessageListener

Fields Summary
Constructors Summary
public JmsClient_TicketConsumer()

            
        Context jndiContext = getInitialContext();
        
        QueueConnectionFactory factory = (QueueConnectionFactory)
			jndiContext.lookup("java:comp/env/jms/QueueFactory");
        
        Queue ticketQueue = (Queue)
			jndiContext.lookup("titan-TicketQueue");

        QueueConnection connect = factory.createQueueConnection();

        QueueSession session = 
			connect.createQueueSession(false,Session.AUTO_ACKNOWLEDGE); 
        
        QueueReceiver receiver = session.createReceiver(ticketQueue);

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

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

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


        try {
        
			ObjectMessage objMsg = (ObjectMessage)message;
			TicketDO ticket = (TicketDO)objMsg.getObject();
			System.out.println("********************************");
			System.out.println(ticket);
			System.out.println("********************************");
        
        } catch (JMSException jmsE) {
            jmsE.printStackTrace();
        }
       System.out.println("finished consuming");