U S I N G   T H E   J M S   A P I  
Using Message Driven Beans (MDB) with Jboss 
A message driven bean is JMS message listner that is managed by a J2EE container.  An 
example of a MDB is show in Listing 11 5, the source code for a simple MDB. 
Listing 11 5, the source code for a simple MDB 
package example.beans; 
import javax.ejb.MessageDrivenBean; 
import javax.ejb.MessageDrivenContext; 
import javax.ejb.EJBException; 
import javax.jms.MessageListener; 
import javax.jms.Message; 
public class PrintBean implements MessageDrivenBean, MessageListener { 
  public void setMessageDrivenContext(MessageDrivenContext c) throws EJBException {} 
  public void ejbCreate() {} 
  public void ejbRemove() {} 
  public void onMessage(Message message) { 
    System.err.println("Got Message: " + message.toString()); 
  } 
}  
The ejb jar.xml deployment descriptor for the example MDB configures how messages are 
delivered to a MDB.  For example, Listing 11 6, the ejb jar.xml deployment descriptor 
configures a bean named PrintBean which will receive messages from a queue with no 
message selector and who's transaction will be bean managed and messages will be auto 
acknowledged by the JMS provider. 
Listing 11 6, the ejb jar.xml deployment descriptor 
 
 
 
   
     
      PrintBean 
      example.beans.PrintBean 
       
      Bean 
      Auto acknowledge 
       
      javax.jms.Queue 
       
     
   
 
104






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

best web hosting

 

Our partners: PHP: Hypertext Preprocessor Cheap Web Hosting JSP Web Hosting Ontario Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Java Hosting Cheapest Hosting

Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved