The P4 protocol is an SAP proprietary protocol that facilitates communication between remote objects from different namespaces (possibly different hosts). It is related to the Remote Method Invocation (RMI) and Common Object Request Broker Architecture (CORBA) technologies, and its implementation combines features of both of them.
The P4 protocol also has some specific features that make it well-suited to the SAP NetWeaver Application Server for Java (AS Java) cluster architecture and provides transparent, robust failover and load balancing mechanisms.
The P4 protocol is designed to work in both standalone and cluster environments.
RMI-P4 refers to the development framework that is used to develop distributed remote Java objects applications on AS Java . It is based entirely on the P4 protocol. The framework and the protocol functions are logically concentrated in the P4 Provider Service.
The RMI-P4 system provides the functions that meet the requirements of applications based on the Distributed Object Model. The distributed applications consist of two parts - a client part and a server part. RMI-P4 enables the mechanism by which client and server parts communicate, which includes:
Locating the remote object
Communication with the remote object
Loading classes of objects that are transmitted in the communication process
The RMI-P4 system provides the following functions:
A standard mechanism for the communication between remote objects using stubs and skeletons. To simplify development, the stubs and skeletons are now transparently generated by the RMI-P4 system at runtime.
A stub is a local representation of the remote object residing on the client JVM. It serves as a proxy responsible for transmitting the client call to the implementation of the remote object. The skeleton is located in the JVM where the remote object resides. It is responsible for "unmarshaling" the parameters of the remote call and passing them to the remote object implementation.
Effective garbage collection
The P4 Provider Service has a reference-counting garbage collection mechanism which automatically removes objects that are not referenced by any clients.
Load balancing
Client RMI-P4 requests are load balanced at the point where the client creates an InitialContext and obtains a reference to the remote server-side object using it.
In an AS Java cluster with several Java instances, you have two options for load balancing client RMI-P4 requests. You can send a request to a particular Java instance and have it dispatched to any of the server processes within it. Or, you can use the message server for cluster-wide load balancing - the message server sends the request to an available Java instance in the cluster. To select any of the two options, you provide specific parameters in your remote client code when creating the InitialContext. More information: Creating an Initial Context
Transparent failover for clustered remote objects
RMI-P4 implements a mechanism for migrating instances of clustered remote objects to other available server processes within the AS Java cluster in case a server process crashes.
Reliable network connections between remote clients and servers, supporting different connectivity options, such as encryption (SSL), HTTP tunneling and connections via SAP router. More information: Network Configuration for RMI-P4
You can use the features and functions provided by RMI-P4 when developing your distributed applications on AS Java . More information: Developing Distributed Applications Based on RMI-P4
Reference
The P4 protocol and service aim to provide transparency and usability to the client. However, P4 also offers possibilities for custom configurations. More information:
Using P4 Protocol Over a Secure Connection
Network Configuration for RMI-P4
Advanced P4 Protocol Connection Configuration