|
WebLogic Server 7.0 Code Examples, BEA Systems, Inc. | |||||
See:
Description
| 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. |
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:
prompt> cd %SAMPLES_HOME%\src\examples\cluster\rmi
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\stage\examples\serverclasses.
cluster\rmi directory:
cd %SAMPLES_HOME%\src\examples\cluster\rmi
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:
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
|
Documentation is available at http://e-docs.bea.com/wls/docs70 |
|||||