FileDocCategorySizeDatePackage
JmsClient_TicketConsumer.javaAPI DocExample2140Wed May 29 21:20:04 BST 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 ("ConnectionFactory");
      
      Queue ticketQueue = (Queue)
      jndiContext.lookup ("queue/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 displayed)
      {
         displayed.printStackTrace ();
      }