JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle GlassFish Server 3.1-3.1.1 High Availability Administration Guide
search filter icon
search icon

Document Information


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

Load Balancing Models

InitialContext Load Balancing

InitialContext Summary

InitialContext Algorithm

Enabling RMI-IIOP Hardware Load Balancing and Failover

To Enable RMI-IIOP Hardware Load Balancing for the Application Client Container

Per-Request Load Balancing (PRLB)

PRLB Summary

Enabling Per-Request Load Balancing

To Enable RMI-IIOP Per-Request Load Balancing for a Stateless EJB


Per-Request Load Balancing (PRLB)

The following topics are addressed here:

PRLB Summary

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.

Enabling Per-Request Load Balancing

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.

To Enable RMI-IIOP Per-Request Load Balancing for a 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.

  1. Choose or assemble the EJB that you want to deploy.

    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:

  2. Set the per-request-load-balancing property to true in the glassfish-ejb-jar.xml deployment descriptor file for the EJB.

    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.

  3. Deploy the EJB.

    If the EJB was previously deployed, it must be redployed.

    For instructions on deploying EJBs, refer to the following documentation:

  4. (Optional) Verify the PRLB configuration by looking for the following FINE message in the CORBA log file:
    Setting per-request-load-balancing policyfor EJB EJB-name
  5. Configure a client application to access the PRLB-enabled EJB.

    For example:

    public class EJBClient {
        public static void main(String args[]) {
        try {
        // only one lookup
        Object objref = initContext.lookup("test.cluster.loadbalancing.ejb.\
            myGreeterRemote = (TestSessionBeanRemote)PortableRemoteObject.narrow\
        } 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.