Skip Navigation Links | |
Exit Print View | |
Oracle GlassFish Server 3.1-3.1.1 High Availability Administration Guide |
1. High Availability in GlassFish Server
2. Setting Up SSH for Centralized Administration
3. Administering GlassFish Server Nodes
4. Administering GlassFish Server Clusters
5. Administering GlassFish Server Instances
6. Administering Named Configurations
7. Configuring Web Servers for HTTP Load Balancing
8. Configuring HTTP Load Balancing
9. Upgrading Applications Without Loss of Availability
10. Configuring High Availability Session Persistence and Failover
11. Configuring Java Message Service High Availability
12. RMI-IIOP Load Balancing and Failover
General Requirements for Configuring Load Balancing
Enabling RMI-IIOP Hardware Load Balancing and Failover
To Enable RMI-IIOP Hardware Load Balancing for the Application Client Container
The following topics are addressed here:
Per Request Load Balancing (PRLB) is a method for load balancing stateless EJBs that enables load-balancing for each request to an EJB instance. PRLB chooses the first node in a cluster to use on each request. By contrast, InitialContext (hardware) load balancing chooses the first node to use when the InitialContext is created, and each request thereafter uses the same node unless a failure occurred.
PRLB is enabled by means of the boolean per-request-load-balancing property in the glassfish-ejb-jar.xml deployment descriptor file for the EJB. If this property is not set, the original load balancing behavior is preserved.
Note - PRLB is only supported for stateless session beans. Using PRLB with any other bean types will result in a deployment error.
You can enable Per-Request Load Balancing (PRLB) by setting the boolean per-request-load-balancing property to true in the glassfish-ejb-jar.xml deployment descriptor file for the EJB. On the client side, the initContext.lookup method is used to access the stateless EJB.
This procedure describes how to enable PRLB for a stateless EJB that is deployed to clustered GlassFish Server instances. This procedure also provides an client-side example for accessing a stateless EJB that uses PRLB.
In this example, an EJB named TheGreeter is used.
For instructions on developing and assembling an EJB for deployment to GlassFish Server, refer to the following documentation:
For more information about the glassfish-ejb-jar.xml deployment descriptor file, refer to The glassfish-ejb-jar.xml File in Oracle GlassFish Server 3.1 Application Deployment Guide
For example, the glassfish-ejb-jar.xml file for a sample EJB named TheGreeter is listed below.
<glassfish-ejb-jar> <enterprise-beans> <unique-id>1</unique-id> <ejb> <ejb-name>TheGreeter</ejb-name> <jndi-name>greeter</jndi-name> <per-request-load-balancing>true</per-request-load-balancing> </ejb> </enterprise-beans> </glassfish-ejb-jar>
If the EJB was previously deployed, it must be redployed.
For instructions on deploying EJBs, refer to the following documentation:
Setting per-request-load-balancing policyfor EJB EJB-name
For example:
public class EJBClient { public static void main(String args[]) { : : : try { // only one lookup Object objref = initContext.lookup("test.cluster.loadbalancing.ejb.\ TestSessionBeanRemote"); myGreeterRemote = (TestSessionBeanRemote)PortableRemoteObject.narrow\ (objref, TestSessionBeanRemote.class); } catch (Exception e) { : } for (int i=0; i < 10; i++ ) { // method calls in a loop. String theMessage = myGreeterRemote.sayHello(Integer.toString(i)); System.out.println("got"+": " + theMessage); } } }
See Also
See Enabling the High Availability Session Persistence Service for instructions on enabling the session availability service for a cluster or for a Web, EJB, or JMS container running in a cluster.