Designing the Message-Driven Bean

Figure 14.2 shows the design of the OrderVerifier component. The OrderVerifierMDB message-driven bean implements the javax.ejb.MessageDrivenBean and javax.jms.MessageListener interfaces. It implements the methods setMessageDrivenContext() and ejbRemove() as defined in the javax.ejb.MessageDrivenBean and the onMessage() method, as defined in the javax.jms.MessageListener interface. It also implements the ejbCreate() method.

Figure 14.2. OrderVerifierMDB message-driven bean design.


The OrderVerifier bean expects the text message to contain the primary key of the order. It locates the order in the database by using its primary key and checks the student billing information and so on. After the order information is verified, it changes the order's status to “Verified.” For simplicity, we don't write code to verify the student information, but merely set the order status to Verified. The OrderVerifier component uses the Order component that you developed and deployed on Day 11, “Developing Container-Managed Persistence Entity Beans.”

Note

Clients don't access message-driven beans through interfaces. Unlike session and entity beans, message-driven beans have neither a home nor a component interface. A client accesses a message-driven bean through JMS by sending messages to the JMS Destination (Queue or Topic) for which the MDB class is the MessageListener.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.206.69