user manual

200 BES Developers Guide
Transaction manager services
transaction, the OTS engine is needed to reliably complete the transaction
using the two-phase commit protocol. Sample scenarios include:
A session bean accesses two types of entity beans in a transaction where
each are persisted in a different database.
A session bean accesses an entity bean and in the same transaction does
some messaging work, such as sending a message to a JMS queue.
In the onMessage method of a message-driven bean, access entity beans on
message delivery.
In each of the above examples, two heterogeneous resources need to be
accessed from within a session bean or a message-driven bean as part of a
single transaction. These EJBs have the REQUIRED transaction attribute defined
and need access to the OTS engine. However, if the OTS engine is running,
then all modules deployed to that Partition are able to discover it and can
attempt to use it. The OTS engine will perform a one-phase commit when only
one resource is registered in a transaction, but suffers the extra RMI overhead
since it is an external process. Ideally, the in-process Transaction Manager
should be used for EJBs not involved in a two-phase commit transaction. To
better utilize the transaction services available in BES, a bean-level property,
ejb.transactionManagerInstanceName may be specified for EJBs that require 2PC
transaction completion. This property provides the name of the OTS engine to
be used by the EJB container doing transaction demarcation on any of the
methods for the relevant bean. Both the Transaction Manager and the OTS
engine may be available for all EJBs but only those that do not have
ejb.transactionManagerInstanceName specified will discover the Transaction
Manager.
This property can be commonly used for session or message-driven beans
since transactions are usually demarcated in a session bean facade or the
onMessage method of a message-driven bean.
To set the ejb.transactionManagerInstanceName property use the Management
Console. Navigate to your deployed EJB module, right-click on it and select
"DDEditor". In the DDEditor select the required bean from the Navigation
Pane. Select the "Properties" tab and add the
ejb.transactionManagerInstanceName property. Define the property as a String
and specify a unique name value such as "MyTwoPhaseEngine".
Next, you must modify the OTS engine factory name with the
ejb.transactionManagerInstanceName value. In the Management Console, select
the OTS engine from the "corbaSample" configuration, identified as the "OTS
engine" managed object type. Right-click and select "Properties" from the
drop-down menu. In the Properties dialog choose the Settings tab and modify
the value for "Factory Name". Click OK, and restart the service. The OTS
engine may also be started from the command line, independent of a BES
server. The factory name can be provided using property vbroker.ots.name as
follows: :
prompt> ots -Dvbroker.ots.name=<MyTwoPhaseEngine>
The EJB will now use the OTS engine named "MyTwoPhaseEngine". As
mentioned, the Partition may be hosting several J2EE modules, but only those