All Examples

package examples.cluster.rmi

Interface Index

  • HelloCluster
  • Class Index

  • HelloClusterClient
  • HelloClusterImpl
  • about this package

    Note: You'll need a cluster license in order to run this example in a cluster environment. Contact your sales rep for more information.

    This simple RMI example is generated with the "-clusterable" flag and is registered as a startup class in the per-cluster properties file, which binds the impl into the cluster-wide, replicated naming tree. The stub that a HelloClient receives can failover and load balance in a cluster.

    There isn't anything particularly different about this example from any other RMI example -- which is important to point out -- except in its generation. Note that you add the "-clusterable" flag to generate a cluster-aware stub.

    You can also set up this example so that it operates as a "pinned" RMI object. In that case, leave off the "-clusterable" flag when you run RMIC, and register the startup class in the per-server properties file for the server where you want the service to be bound. In that case, the service itself will be available from any server in the cluster since all the cluster servers know how to return the unreplicated stub, but if the particular server that hosts the pinned service fails, the service itself will not failover.

    how to run these examples

    1. You can use the scripts supplied in this directory (build.cmd for Windows NT, build.sh for UNIX) or you can follow these steps:

      1. Set up your development environment as described in Setting your development environment.

      2. Compile the Java files in this directory and the examples/cluster/utils directory into the WebLogic classes directory, with the javac -d option, as shown in this example for Windows NT:
         $ javac -d %SERVER_CLASSES% HelloCluster.java
         $ javac -d %CLIENT_CLASSES% HelloClusterClient.java
         $ javac -d %SERVER_CLASSES% HelloClusterImpl.java

      3. Run WebLogic's RMIC on the HelloClusterImpl class. Note that you must set the "-clusterable" flag to generate a stub that will replicate properly throughout the cluster naming tree and will handle load balancing and failover properly. Here's an example, to be entered on a single line:
         $ java weblogic.rmic -d %SERVER_CLASSES% -clusterable 
            -methodsAreIdempotent -keepgenerated -commentary examples.cluster.rmi.HelloClusterImpl

    2. Register the HelloImpl class as a startup class in the per-cluster properties file -- the weblogic.properties file in the mycluster/ directory:
       weblogic.system.startupClass.HelloClusterImpl=examples.cluster.rmi.HelloClusterImpl

    3. In a separate command line window (set up as described in Setting your development environment), run the client by entering on a single line:
      $ java examples.cluster.rmi.HelloClusterClient -url t3://any cluster node:7001

      where parameters are:

    there's more . . .

    Check out the clustered EJB example in the cluster directory.

    You can read more information about configuring a WebLogic Cluster and writing clustered applications in the Developers Guide, WebLogic Clusters.

    Copyright © 1998-2000 BEA Systems, Inc. All rights reserved.

    Last updated 09/16/1999