J2EE Messaging 905 Now start up the StockGuy and enter in some stock symbols. Notice that when you enter symbols that the PurchaserGuy isn't interested in receiving, it won't print them out on the screen: When the PurchaserGuy receives quotes, you can choose whether or not you want to purchase the stock at that price and you can send a buy order: Notice that if two different StockGuy clients are sending quotes to the same PurchaserGuy and the PurchaserGuy makes a purchase order, the order will go to the StockGuy who published the stock quote that the Purchaser decided to buy on. Type in q or Q to exit each of the programs. Message-Driven EJBs In addition to the entity and session bean types that are defined in the EJB 1.1 specification, the EJB 2.0 specification contains the definition of a new bean type, the message-driven bean. A message-driven bean may receive JMS messages (in other words a message-driven bean is a JMS message consumer). Like a standard JMS message consumer, a message-driven bean receives messages from a JMS queue or topic and performs business logic based on the message contents. Message-Driven Beans vs. Ordinary JMS Message Consumers A message-driven bean provides the developer with a few advantages over an ordinary JMS message consumer. The first advantage that a message-driven bean has is the support that the container provides for all EJBs, such as support for security, scalability, transactions, and database connectivity. Also, message-driven beans are more portable than ordinary JMS consumers. A message-driven bean is not coded to listen on a particular topic or queue, the developer specifies the destination that the bean listens on in the deployment descriptor; therefore the developer does not need to specify the topic or queue the bean listens on until deployment time.