Book Image

EJB 3.1 Cookbook

By : Richard M. Reese
Book Image

EJB 3.1 Cookbook

By: Richard M. Reese

Overview of this book

<p>Enterprise Java Beans enable rapid and simplified development of secure and portable applications based on Java technology.Creating and using EJBs can be challenging and rewarding. Among the challenges are learning the EJB technology itself, learning how to use the development environment you have chosen for EJB development, and the testing of the EJBs.<br /><br />This EJB 3.1 Cookbook addresses all these challenges and covers new 3.1 features, along with explanations of useful retained features from earlier versions. It brings the reader quickly up to speed on how to use EJB 3.1 techniques through the use of step-by-step examples without the need to use multiple incompatible resources. The coverage is concise and to the point, and is organized to allow you to quickly find and learn those features of interest to you.<br /><br />The book starts with coverage of EJB clients. The reader can choose the chapters and recipes which best address his or her specific needs. The newer EJB technologies presented include singleton beans which support application wide needs and interceptors to permit processing before and after a target method is invoked. Asynchronous invocation of methods and enhancements to the timer service are also covered. <br /><br />The EJB 3.1 CookBook is a very straightforward and rewarding source of techniques supporting Java EE applications.</p>
Table of Contents (19 chapters)
EJB 3.1 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Introduction


A Message-Driven Bean (MDB) implements business logic in an asynchronous fashion. The client does not receive a response to the message from the MDB. A client will send a message to a queue or topic. The message is then retrieved and processed by the MDB. A queue differs from a topic in that a message in a queue is sent to a single MDB. In contrast, a message in a topic will be sent to each MDB that is registered with that topic.

From the client's perspective, the MDB is anonymous. There is no way for the client to identify or otherwise select a specific MDB. The EJB container decides which MDB object to use in response to a request. In order to send a message to an MDB, the client can use dependency injection or JNDI lookup to locate the queue or topic.

MDBs are managed by the server EJB container. The EJB container will treat all instances of the same MDB class identically. A message will be delivered to the next available instance of the MDB. The container will create and...