Rpc=remote Procedure Call
Computer A can invoke the method of remote computer B just as the local method is called, omitting the details of displaying the encoded remote call
Process: User is equivalent to a client, when the client calls the remote method, User-stub the interface method parameters, the protocol data packaged into RPC through a specific protocol specification is sent by the C-end rpcruntime to the S-end rpcruntime, When the S-end is received, it is parsed according to a specific protocol specification, and then the local method is called, and the results are returned to the client
RPC Calls:
Synchronous invocation: The client waits for the call to finish and returns the result
Asynchronous invocation: The client call does not have to wait for the execution result to return, but can still get the return result by callback notification, etc.
If the client does not care about calling the return result, it becomes a one-way asynchronous call, and one-way calls do not return results
Difference: Whether to wait for the service side to finish and return the results
RpcProxy equivalent to user,rpcinvoker equivalent to user-stub,rpcconnector equivalent to Rpcruntime, vice versa Also
Rpcinvoker: Responsible for encoding the call information and sending the call request to the service party and waiting for the call result to return (Client)
Responsible for invoking the specific implementation of the server-side interface and returning the call result (Server)
Example:
Export exported interface:
RpcServer server = new ...;
DemoService demo = new ...;
DemoService demo2 = new ...;
server.export(DemoService.class,demo,options)
server.export("demo2",DemoService.class,demo,options)
Import Interface:
RpcClient client = new ...;
DemoService demo = client.refer(DemoService.class);
demo.hi("rpc hello");
Protocol compression:
Similar to HTTP has header information and body information, body information is serializable encoding, such as Xml,json
Exception handling:
1.RPC calls do not necessarily perform
The 2.RPC framework itself throws an exception
3.RPC speed (ms) is definitely slower than local call (NS)
Experience:
Because the RPC call process will have network consumption, only when the task time is much larger than the RPC intrinsic consumption time, the comparison is applicable
RPC Service Brief