Message-Driven Beans

MDBs are a new addition to J2EE. As mentioned previously, these beans provide a mechanism for providing a messaging server within the application server using EJB components. Prior to the inclusion of MDBs in the J2EE specification, application server vendors provided their own messaging services. While having a messaging service available was useful, what was really needed was a facility to perform messaging processing in the context of the EJB container. MDBs provide that capability using the JMS package interface.

The following code provides an example of a minimal implementation of an MDB. The client application creates a message, locates the message queue, and then sends the message. The server component, the MDB, is ...

Get J2EE™ and Beyond: Design, Develop, and Deploy World-Class Java™ Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.