In this chapter:
Message-Driven EJB Lifecycle
Writing Deployment Descriptors for Message-Driven Beans
Message-Driven Beans and Concurrency
Using Transactions with Message-Driven Beans
Message-Driven Bean Advantages
Session and entity beans use a well-defined interface for processing workflow from client requests. Enterprise JavaBeans (EJB) clients use the home and remote interfaces to make synchronous Remote Method Invocation (RMI) calls to the EJB server. The client thread making the EJB call blocks until the EJB server call returns. As discussed in Chapter 7, Enterprise Messaging with the Java Message Service (JMS), messaging allows an asynchronous model. Instead of waiting for the server's response, the client sends a message to a JMS destination and returns. In addition to scalability benefits, this model enables client programs to continue without waiting for server operations to complete.
In the EJB 1.0 and 1.1 specifications, it was difficult to integrate the synchronous EJB model with messaging systems. EJBs can be used to send messages, but session and entity beans cannot be used as JMS message listeners. The problem is that session and entity beans instances live within the EJB container, and the EJB container determines their lifecycle. With the EJB 2.0 specification, there is a new EJB type that integrates EJB and JMS. This new EJB type is the message-driven EJB.
3.134.79.121