Package examples.cluster.rmi

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.

See:

 

Interface Summary

HelloCluster This interface is the remote interface for the weblogic.rmi.
 

 

Class Summary

HelloClusterClient Client for simple clustered RMI service example.
HelloClusterImpl This class implements the interface HelloCluster.
 

Package examples.cluster.rmi Description

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.

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

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 this 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 this 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.

These three sections cover what to do:

  1. Build the Example
  2. Configure the Server
  3. Run the Example

Build the Example

  1. Set up your development shell as described in the examples Basic Steps.

  2. Move to the cluster RMI example directory:
    prompt> cd %SAMPLES_HOME%\src\examples\cluster\rmi
  3. Use the Java ant command to compile the files in this directory with the supplied config.xml build script:
    prompt> ant compile_client

    The build script compiles the example's .java files and uses weblogic.rmic to generate the clustered stub. The final classes are placed in %SAMPLES_HOME%\server\examples\build\serverclasses.

Configure the Server

  1. Configure a WebLogic Server cluster, if you have not already done so and start the clustered servers.
  2. Bring up the Administration Console in your browser.
  3. Click to expand the Startup & Shutdown node in the left-hand pane.
  4. Select the hello_cluster node. The hello_cluster configuration displays in the right-hand pane.
  5. Select the Targets tab to display the Available and Chosen targets.
  6. Deploy hello_cluster on your configured cluster.

Run the Example

  1. In a separate command-line window, set up your development shell as described in the examples Basic Steps.
  2. Return to the cluster\rmi directory:
    cd %SAMPLES_HOME%\src\examples\cluster\rmi
  3. Run the client by editing the run target in the build.xml file to reflect your cluster ip address and port. Then enter on a single line:
    prompt> ant run

    where the parameters in the build.xml are:

    • -url t3://ClusterAddress:listen_port, which contains a URL such as "t3://www.setgetweb.com:7001" of a server in a cluster
    • ClusterAddress, which can be either the DNS name or the name of any node in the cluster.
    • listen_port, which is the listen port number you set when you installed WebLogic Server (by default, 7001)

    The client application displays output similar to the following:

    Hello World from : server2
    Hello World from : server1
    Hello World from : server2
    Hello World from : server1
    Hello World from : server2
    Hello World from : server1
    Hello World from : server2
    Hello World from : server1
    Hello World from : server2
    Hello World from : server1
    Hello World from : server2
    
    Completed 10 iterations with 0 number of exceptions.
    
    Now processing aggregate results.
    
    
    "server2" processed 5 (50%) of 10 invocations
    "server1" processed 5 (50%) of 10 invocations