Share this page

# RMI over IIOP protocol

VuGen provides full support for the RMI over IIOP protocol.

This section describes the elements of the Java Vuser script that are specific to RMI.

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 .

RMI does not have constructs. Instead, it uses Serializable Java objects. In RMI there is no specific shutdown section.

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.

Example:

    Import java.rmi.*;
    Import java.rmi.registry.*;

    public int action() throws Throwable {

        _registry = LocateRegistry.getRegistry("localhost",1099);
        counter = (Counter)_registry.lookup("Counter1");
        counter.set_sum(0);
        counter.increment();
        counter.increment();
        counter.get_sum();
        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 Java scripts correlation - serialization.

Connection timeouts

To set connection timeouts, add Java code to set the properties.

The following example shows setting RMI timeouts to 5 seconds:

Example:

    import lrapi.lr;
    public class Actions {
      public int init() throws Throwable {
        return 0;
      }
      public int action() throws Throwable {
        java.util.Properties properties=System.getProperties();

        properties.put("sun.rmi.transport.tcp.responseTimeout", 5000);
        properties.put("sun.rmi.transport.tcp.readTimeout", 5000);
        properties.put("sun.rmi.transport.connectionTimeout", 5000);
        properties.put("sun.rmi.transport.handshakeTimeout", 5000);

        properties.put("user.script","");
        System.setProperties(properties);
        java.lang.String var_0="rmi://example.com/RmiServer";
        RmiServerIntf var_1=(RmiServerIntf)java.rmi.Naming.lookup(var_0);
        java.lang.String var_2=var_1.getMessage();
        return 0;
      }
      public int end() throws Throwable {
        return 0;
      }
    }

To set this timeout to all TCP connections:

        properties.put("sun.net.client.defaultReadTimeout", 5000);
        properties.put("sun.net.client.defaultConnectTimeout", 5000);

Back to top

See also:

- Supported Java communication protocols
- Java Record Replay protocol recording tips

https://admhelp.microfocus.com VuGen,Professional Performance Engineering,Performance Engineering for Developers 8942
Tips to improve your search results... OpenText™ Virtual User Generator Help Center OpenText™ VuGen Help 26.1 All View Local Help Center View Online Help Center Version: