124
Chapter 9. Developing Message-Driven Beans
configuration (for example, distribution, multi-servers), refer to the JORAM documentation on
http://joram.objectweb.org.
9.5. Transactional Aspects
Because a transactional context cannot be carried by a message (according to the EJB 2.1 speci-
fication), an MDB will never execute within an existing transaction. However, a transaction may
be started during the
method execution, either due to a "required" transaction attribute
onMessage
(container-managed transaction) or because it is explicitly started within the method (if the MDB is
bean-managed transacted). In the second case, the message receipt will not be part of the transac-
tion. In the case of the container-managed transaction, the container starts a new transaction before
de-queuing the JMS message (the receipt of which will, thus, be part of the started transaction), then
enlist the resource manager associated with the arriving message and all the resource managers ac-
cessed by the
method. If the
method invokes other Enterprise Beans, the
onMessage
onMessage
container passes the transaction context with the invocation. Therefore, the transaction started at the
method execution may involve several operations, such as accessing a database (via a call
onMessage
to an Entity Bean, or by using a "datasource" resource), or sending messages (by using a "connection
factory" resource).
9.6. Message-Driven Beans Example
JOnAS provides examples that are located in the
install directory.
examples/src/mdb
is a very simple example, the code of which is used in the previous topics for illustrating
samplemdb
how to use Message-Driven Beans.
is a more complex example that shows how the sending of JMS messages and updates
sampleappli
in a database via JDBC may be involved in the same distributed transaction.
The following figure illustrates the architecture of this example application.
Need help?
Do you have a question about the APPLICATION SERVER - JONAS and is the answer not in the manual?
Questions and answers