background image

Managing Distributed Transactions

<< Stateless Session Bean | Container-Managed Transactions >>
<< Stateless Session Bean | Container-Managed Transactions >>

Managing Distributed Transactions

Figure 31­11
shows the life cycle of a message-driven bean.
Managing Distributed Transactions
JMS client applications use JMS API local transactions (described in
"Using JMS API Local
Transactions" on page 947
), which allow the grouping of sends and receives within a specific
JMS session. Java EE applications commonly use distributed transactions to ensure the integrity
of accesses to external resources. For example, distributed transactions allow multiple
applications to perform atomic updates on the same database, and they allow a single
application to perform atomic updates on multiple databases.
In a Java EE application that uses the JMS API, you can use transactions to combine message
sends or receives with database updates and other resource manager operations. You can access
resources from multiple application components within a single transaction. For example, a
servlet can start a transaction, access multiple databases, invoke an enterprise bean that sends a
JMS message, invoke another enterprise bean that modifies an EIS system using the Connector
architecture, and finally commit the transaction. Your application cannot, however, both send a
JMS message and receive a reply to it within the same transaction; the restriction described in
"Using JMS API Local Transactions" on page 947
still applies.
Does Not
Exist
Ready
1. Dependency injection, if any
2. PostConstruct callback, if any
PreDestroy callback, if any
onMessage
FIGURE 31­11
Life Cycle of a Message-Driven Bean
Using the JMS API in a Java EE Application
The Java EE 5 Tutorial · September 2007
958