RPC Service Brief

Source: Internet
Author: User

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:

  1. RpcServer server = new ...;

  2. DemoService demo = new ...;

  3. DemoService demo2 = new ...;

  4. server.export(DemoService.class,demo,options)

  5. server.export("demo2",DemoService.class,demo,options)

Import Interface:

    1. RpcClient client = new ...;

    2. DemoService demo = client.refer(DemoService.class);

    3. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.