Stateless Session Beans When a home creates a stateless bean, it returns a Stateful Session Beans Method-level failover for a stateful service requires

Failover and Replication in a Cluster 6-21

6.3.2.1 Clustered EJBHomes

All bean homes interfaces—used to find or create bean instances—can be clustered, by specifying the home-is-clusterable element in weblogic-ejb-jar.xml. When a bean is deployed to a cluster, each server binds the beans home interface to its cluster JNDI tree under the same name. When a client requests the beans home from the cluster, the server instance that does the look-up returns a EJBHome stub that has a reference to the home on each server. When the client issues a create or find call, the stub selects a server from the replica list in accordance with the load balancing algorithm, and routes the call to the home interface on that server. The selected home interface receives the call, and creates a bean instance on that server instance and executes the call, creating an instance of the bean.

6.3.2.2 Clustered EJBObjects

An EJBObject stub tracks available replicas of an EJB in a cluster.

6.3.2.2.1 Stateless Session Beans When a home creates a stateless bean, it returns a

EJBObject stub that lists all of the servers in the cluster, to which the bean should be deployed. Because a stateless bean holds no state on behalf of the client, the stub is free to route any call to any server that hosts the bean. The stub can automatically fail over in the event of a failure. The stub does not automatically treat the bean as idempotent, so it will not recover automatically from all failures. If the bean has been written with idempotent methods, this can be noted in the deployment descriptor and automatic failover will be enabled in all cases.

6.3.2.2.2 Stateful Session Beans Method-level failover for a stateful service requires

state replication. WebLogic Server satisfies this requirement by replicating the state of the primary bean instance to a secondary server instance, using a replication scheme similar to that used for HTTP session state. When a home interface creates a stateless session bean instance, it selects a secondary instance to host the replicated state, using the same rules defined in Section 6.2.1.2, Using Replication Groups. The home interface returns a EJBObject stub to the client that lists the location of the primary bean instance, and the location for the replicated bean state. Note: Stateless session beans, stateful session beans, and entity beans have home interfaces. Message-driven beans do not. Note: WebLogic Server supports load balancing algorithms that provide server affinity for EJB home interfaces. To understand server affinity and how it affects load balancing and failover, see Section 5.2.4.3, Round-Robin Affinity, Weight-Based Affinity, and Random-Affinity. Note: WebLogic Server supports load balancing options that provide server affinity for stateless EJB remote interfaces. To understand server affinity and how it affects load balancing and failover, see Section 5.2.4.3, Round-Robin Affinity, Weight-Based Affinity, and Random-Affinity. 6-22 Using Clusters for Oracle WebLogic Server Figure 6–8 shows a client accessing a clustered stateful session EJB. Figure 6–8 Client Accessing Stateful Session EJB As the client makes changes to the state of the EJB, state differences are replicated to the secondary server instance. For EJBs that are involved in a transaction, replication occurs immediately after the transaction commits. For EJBs that are not involved in a transaction, replication occurs after each method invocation. In both cases, only the actual changes to the EJBs state are replicated to the secondary server. This ensures that there is minimal overhead associated with the replication process.

6.3.2.2.3 Failover for Stateful Session EJBs Should the primary server fail, the clients EJB