Summary
Message-Driven beans make JMS programming much easier. The container provides many infrastructural services so that application developers can focus on the business logic of the asynchronous processing. Asynchronous processing can at times be very useful or even indispensable.
Message-Driven beans are in many ways similar to Stateless Session beans. But unlike Session beans and Entity beans, MDBs are never invoked directly by clients; therefore, they don't need home interfaces and remote objects. For developers, this means that there needs just one source file for a bean, plus appropriate deployment descriptors. The majority of Message-Driven bean development is done in the onMessage() method of the javax.jms.MessageListener interface, which every MDB class must implement.
The design pattern for Message-Driven beans is, naturally, Service Activator; that is, clients post messages to request services, and MDBs delegate them to appropriate Entity beans or other services.
|