Java Reference
In-Depth Information
FIGURE 21-2. Transactions: JMS Client Example
The example contains five classes:
GenericSupplier
,
Order
,
Retailer
,
Vendor
, and
VendorMessageListener
. The example also contains a
main
method
and a method that runs the threads of the
Retailer
,
Vendor
, and two supplier classes.
All the messages use the
MapMessage
message type. Synchronous receives are used for
all message reception except when the vendor processes the replies of the suppliers. These
replies are processed asynchronously and demonstrate how to use transactions within a
message listener.
At random intervals, the
Vendor
class throws an exception to simulate a database prob-
lem and cause a rollback.
All classes except
Retailer
use transacted sessions.