background image

HR Department Application

<< Using the JMS API with an Entity | Writing the Application Components >>
<< Using the JMS API with an Entity | Writing the Application Components >>

HR Department Application

The basic steps of the application are as follows.
1. The HR department's application client generates an employee ID for each new hire and
then publishes a message (M1) containing the new hire's name, employee ID, and position.
The client then creates a temporary queue, ReplyQueue, with a message listener that waits
for a reply to the message. (See
"Creating Temporary Destinations" on page 941
, for more
information.)
2. Two message-driven beans process each message: One bean, OfficeMDB, assigns the new
hire's office number, and the other bean, EquipmentMDB, assigns the new hire's equipment.
The first bean to process the message creates and persists an entity named SetupOffice,
then calls a business method of the entity to store the information it has generated. The
second bean locates the existing entity and calls another business method to add its
information.
3. When both the office and the equipment have been assigned, the entity business method
returns a value of true to the message-driven bean that called the method. The
message-driven bean then sends to the reply queue a message (M2) describing the
assignments. Then it removes the entity. The application client's message listener retrieves
the information.
Figure 32­2
illustrates the structure of this application. Of course, an actual HR application
would have more components; other beans could set up payroll and benefits records, schedule
orientation, and so on.
Figure 32­2
assumes that OfficeMDB is the first message-driven bean to consume the message
from the client. OfficeMDB then creates and persists the SetupOffice entity and stores the office
information. EquipmentMDB then finds the entity, stores the equipment information, and learns
that the entity has completed its work. EquipmentMDB then sends the message to the reply queue
and removes the entity.
A Java EE Application That Uses the JMS API with an Entity
Chapter 32 · Java EE Examples Using the JMS API
971