Configuring transactions in the Eclipse Amlen resource adapter
You can use the following information to understand transaction options for Enterprise JavaBeans™ (EJBs), message handling options in Eclipse Amlen for message driven beans (MDBs), and Eclipse Amlen transaction options for J2C connection factories.
Transaction options for EJBs
- Bean managed transactions
- In bean managed transactions, the bean method creates transactions
with the
UserTransaction
interface. The transactions are created when they are needed.
- Container managed transactions
- In container managed transactions, the EJB container provides the transaction context for the bean. This type of transaction is the default option.
For more information about EJB configuration and transaction management, see the Oracle Java™ EE tutorial sections for container or bean managed transactions in the product documentation on the Oracle website.
Eclipse Amlen message handling options for MDBs
You can configure an MDB to run
outside a container transaction scope by specifying either bean managed
transactions or container managed transactions with the transaction
attribute set to NotSupported. The EJB container
automatically acknowledges the messages that are processed by the onMessage()
method,
even if the onMessage()
method fails unexpectedly.
The mode for acknowledging received messages depends upon the configuration
setting for the acknowledgeMode property in the
J2C activation specification.
When unexpected failures are
due to transient system issues, messages can be lost. To prevent this
type of message loss, you can set the enableRollback property
to true
for the J2C activation specifications in
the Eclipse Amlen resource
adapter. By default, enableRollback is set to false
so
all messages are automatically acknowledged. When enableRollback is
set to true
, a message is rolled back to the topic
or queue when the onMessage()
method fails. This
rollback allows the message to be redelivered and reprocessed.
Setting enableRollback to true
is
useful for redelivery of messages when transient issues cause the onMessage()
method
to fail. However, setting enableRollback to true
can
trigger the redelivery of poison messages. A poison message is a message
that a receiving application cannot process. To avoid redelivery of
poison messages when you set enableRollback to true
,
you must ensure that you can handle poison messages in your JMS application.
For more information about handling poison messages, see Poison messages.
Eclipse Amlen transaction options for J2C connection factories
J2C connection factories can be used in various types of Java Platform, Enterprise Edition (Java EE) applications.
The transaction scope of a Java EE application depends on the containers that it uses as well as the configuration of the components that it uses. An application server typically coordinates these activities by using global transactions. However, if you want to force the transaction scope, you can do so by setting the transactionSupportLevel property in the Eclipse Amlen resource adapter for connection objects that use Eclipse Amlen J2C connection factories. Changing the default setting for transactionSupportLevel must be done only by someone with expert knowledge about the application. You can set the transactionSupportLevel to one of the following values:
- XATransaction
- This setting enables the connection factory object to support
global or local transactions. The application server sets the appropriate
scope.
XATransaction
is the default setting.
- LocalTransaction
- If only one resource manager is required for the application, transactionSupportLevel can
be set to
LocalTransaction
. This setting ensures that only local transaction context is used by connections that are configured by this connection factory.
- NoTransaction
- If no transactions are required for the application, transactionSupportLevel can
be set to
NoTransaction
. This setting turns off transaction processing for connections that are using the connection factory.
These options can be useful in optimizing connection throughput but must be used with caution. For example, serious application failures can occur if the transactionSupportLevel setting for a J2C connection factory conflicts with the transaction configuration of an EJB that uses the connection factory to create a connection.