Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.1.0) Part Number B28221-02 |
|
|
View PDF |
The general procedure for configuring EJB application clustering for an EJB 3.0 or EJB 2.1 stateful session bean is as follows:
Configure your OC4J application cluster (see "Application Clustering in OC4J" in the Oracle Containers for J2EE Configuration and Administration Guide).
Configure a replication policy for stateful session beans on each node (see "Using Deployment XML").
Configure load-balancing behavior (see "Configuring Load Balancing Behavior").
Deploy your enterprise bean to any one of the nodes in the cluster.
For more information, see the following:
"Stateful Session EJB State Replication with Oracle Application Server Cluster (OC4J)" in the Oracle Application Server High Availability Guide
To configure a replication policy, add a <replication-policy>
element to one or more of the appropriate deployment descriptor files that Table 24-1 lists. You can specify a single replication policy that OC4J applies globally, or specify finer-grained replication policy at the application level for both Web and EJB components, or EJB components only.
Configure the trigger
attribute to one of the following:
inherited
– The stateful session bean uses the state replication trigger setting you configure at the application level. This is the default value.
onRequestEnd
– The state of the stateful session bean is replicated to all hosts in the cluster (with the same multicast address, port) at the end of each EJB method call. If the node loses power, then the state has already been replicated. This method offers less performance than the JVM termination replication mode, because the state is sent out more often. However, the guarantee for reliance is higher.
onShutdown
–The state of the stateful session bean is replicated to only one other host in the cluster (with the same multicast address, port) when the JVM is terminating. This option provides the highest performance, because the state is replicated only once. However, it is not very reliable for the following reasons:
Your state is not replicated if the host is terminated unexpectedly.
The state of the bean exists only on a single host at any time; you carry a higher risk that the state does not replicate and is lost.
none
–Disable clustering for this stateful session bean.
Note:
Using Application Server Control, you cannot configure thetrigger
attribute to inherited
or none
. To set these values, edit the deployment XML manually. For more information, see "Using Oracle Enterprise Manager 10g Application Server Control"The scope
attribute is always set to allAttributes
for a stateful session bean.
For more information, see "State Replication".
Table 24-1 Deployment XML Files for Replication Policy Configuration
Scope | Components | Deployment XML File | See also ... |
---|---|---|---|
Global |
Web and EJB |
|
"Stateful Session EJB State Replication with Oracle Application Server Cluster (OC4J)" in the Oracle Application Server High Availability Guide |
Application-level |
Web and EJB |
|
"Stateful Session EJB State Replication with Oracle Application Server Cluster (OC4J)" in the Oracle Application Server High Availability Guide |
Application-level |
EJB |
|
"Overriding Application-Level Replication Policy in the orion-ejb-jar.xml File for EJB Components" |
When you configure the orion-ejb-jar.xml
file with a state replication policy for a stateful session bean (see Example 24-1), each bean can use a different type of replication independent of the Web component replication type.
Example 24-1 The orion-ejb-jar.xml For an Application-Level Replication Policy for EJB
<orion-ejb-jar> ... <session-deployment name="AirlinePOEndpointBean" max-tx-retries="0" location="AirlinePOEndpointBean" persistence-filename="AirlinePOEndpointBean"> ... <replication-policy trigger="onRequestEnd" scope="allAttributes" /> ... </session-deployment> ... </orion-ejb-jar>