Working with RMI

This section describes the elements of the Java Vuser script that are specific to RMI. VuGen provides full support for the RMI over IIOP protocol.

Depending on what you are recording, you can utilize VuGen's RMI recorder to create a script that will optimally emulate a real user for:

  • Pure RMI client: Recording a client that uses native JRMP protocol for remote invocations
  • RMI over IIOP client: Recording a client application that was compiled using the IIOP protocol instead of JRMP (for compatibility with CORBA servers).

RMI does not have constructs (as in CORBA). Instead, it uses Serializable Java objects. In RMI there is no specific shutdown section (unlike CORBA).

The following code example locates a naming registry and utilizes a lookup operation to obtain a specific Java object. You can then perform functions such as set_sum, increment, and get_sum on the object. You must import the RMI classes to access the RMI functions.

Import java.rmi.*;
Import java.rmi.registry.*;
public int action() throws Throwable {
    _registry = LocateRegistry.getRegistry("localhost",1099);
    counter = (Counter)_registry.lookup("Counter1");
    return lr.PASS;

When recording RMI Java, your script may contain several calls to lr.deserialize, which deserializes all of the relevant objects. The lr.deserialize calls are generated because the object passed to the next invocation could not be correlated to a return value from any of the previous calls. VuGen therefore records its state and calls the lr.deserialize function to represent these values during replay. The deserialization is done before VuGen passes the objects as parameters to invocations. For more information, see How to Correlate Scripts - Java Scripts - Serialization.

To set RMI timeouts, see Specifying connection timeouts.

Note: To replay with a 64-bit JDK, in the Runtime Settings, specify the JDK path in Java VM and select the check box Miscellaneous > Replay script with 64-bit.

Back to top