Java Reference
In-Depth Information
Equipment: Java Phone
Office number: 135
Waiting for 2 message(s)
New hire event processed:
Employee ID: 50
Name: Bill Tudor
Equipment: Desktop System
Office number: 200
Waiting for 1 message(s)
New hire event processed:
Employee ID: 51
Name: Carol Jones
Equipment: Laptop
Office number: 262
The output from the message-driven beans and the entity class appears in the server log,
wrapped in logging information.
For each employee, the application first creates the entity and then finds it. You may see
runtime errors in the server log, and transaction rollbacks may occur. The errors occur if
both of the message-driven beans discover at the same time that the entity does not yet
exist, so they both try to create it. The first attempt succeeds, but the second fails because
the bean already exists. After the rollback, the second message-driven bean tries again
and succeeds in finding the entity. Container-managed transactions allow the application
to run correctly, in spite of these errors, with no special programming.
An Application Example That Consumes Messages from a Remote
Server
This section and the following section explain how to write, compile, package, deploy,
and run a pair of Java EE modules that run on two Java EE servers and that use the JMS
API to interchange messages with each other. It is a common practice to deploy different
components of an enterprise application on different systems within a company, and these
examples illustrate on a small scale how to do this for an application that uses the JMS
API.
The two examples work in slightly different ways. In the first example, the deployment
information for a message-driven bean specifies the remote server from which it will con-
sume messages. In the next example, described in “ An Application Example That Deploys
a Message-Driven Bean on Two Servers on page 436 , the same message-driven bean is
deployed on two different servers, so it is the client module that specifies the servers (one
local, one remote) to which it is sending messages.
Search WWH ::




Custom Search