RPC Framework Research (i) Java callback mechanism

Source: Internet
Author: User

The application of the Ali Middleware performance contest, I am a new challenge, everything from the blank learning, the process of the game is the process of learning

Yes, want to let yourself learn, give yourself a contest it ~

Like the first to learn Weiqi, also reported go game, in order not to lose too miserable, one weeks learned a lot of things


First day Java callback mechanism clear


Let's take a look at the tournament introduction.

The game is divided into two questions: "RPC" and "MOM", both of which need to be completed. We rank the "RPC" score (QPS), the top 100 teams are eligible to enter Mom's tournament, and if they do not go directly to the top 100, the final position will be determined by the "Mom" score.

Game title

First of all, to solve the RPC, starting today, the side learn to solve the problem

RPC Game title

A simple RPC framework

RPC (remote Procedure Call) is a protocol that requests services from a remote computer program over a network without needing to know the underlying network technology. The RPC protocol assumes that some transport protocols exist, such as TCP or UDP, to carry information data between communication programs. In the OSI network communication model, RPC spans the transport and application tiers. RPC makes it easier to develop applications that include distributed, multi-program networks.

Framework--allows programmers to easily use the functionality provided by the framework, due to the RPC characteristics, focus on the application of distributed service development, so become a developer unaware of the interface agent, is clearly the RPC framework excellent design.

Topic Requirements

1. To become a framework: for the user of the framework, hide the RPC implementation.

2. The network module can be written by itself and requires the use of netty-4.0.23.final if the IO framework is to be used.

3. Support asynchronous invocation, provide the ability of future, callback.

4. Ability to transfer basic types, custom business types, exception types (to be thrown on the client).

5. To handle the timeout scenario, the client jumps out of the call at a specified time when the server processing time is longer.

6. Provide RPC context, the client can pass data to the server.

7. Provide hooks to allow developers to perform RPC-level AOP.

Measurement standards

Meet all requirements. Performance testing.


Basic RPC knowledge is not mentioned here, the students themselves refer to the RPC

The implementation of the underlying RPC framework is not difficult, the main use of dynamic Agent technology, the simple is to call the client method proxy to the server side to execute, the server side returns execution results to the client


The difficulty is asynchronous invocation, return exception type, processing timeout scenario, etc.


First, we begin to solve the asynchronous call problem, how to implement the asynchronous framework, refer to Http://www.cnblogs.com/Hybird3D/p/3346582.html


To implement an asynchronous call, you first have to master the Java callback


Callback problem, a bit similar to the principle of Ajax, to pass themselves to each other, when the other side to pass the data to themselves, directly call their own method can be

Reference

http://hellosure.iteye.com/blog/1130176


Today, we'll start with the Java callback principle and use it tomorrow to make an asynchronous RPC framework.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

RPC Framework Research (i) Java callback mechanism

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.