Let me share a personal project into the middleware Ali

Author: vangoleo
official website: http://www.vangoleo.com/iris-java/

background

Time flies, Ali middleware into the team has been almost two years time. During this period, had the honor to participate in the fourth group title Middleware Performance Challenge, with preparations for the "Dubbo Mesh" as the theme of the preliminary question; with the team to carry out activities under the meetup Dubbo line; the middle Ali accumulated 11 years of dual pieces of infrastructure best practices and methodologies, by Ali cloud commercial products, for the majority of developers and enterprises to provide services. Very fortunate to have such an unforgettable experience. In retrospect, we can enter the middleware team, and I had a Github project there relationship. Today, the share of the project to everyone.

Q: What is the middleware team?
A: Alibaba middleware technology department, is one of the world's leading Java technology team, originated in the Taobao platform architecture group, is followed Ali and double eleven electricity supplier business to grow up technical team to solve complex business scenarios, rapid business growth, high peak concurrent big promotion, stability endless. Products include highly distributed RPC service framework, highly reliable distributed messaging middleware layer distributed data, mass data storage, real-time calculation, optimize system performance, high availability and other infrastructure areas of major products, these products support Alibaba All trading and non-trading operations systems Group (Taobao, Lynx, together cost-effective, 1688, rookie), and a smooth ride through the challenges of double eleven turnover of 91.7 billion transaction. Our open-source middleware components Dubbo, Rocketmq, Nacos, tengine, Seata so are many companies and individuals to use.

Invitation from middleware

2017, I led the team to back-end architecture of the micro-service remodeling. Dubbo framework used when shaping. Thanks to Dubbo high performance, simple to use and highly scalable, very smooth micro-services transformation, the company's business is more stable. I also had a strong interest in Dubbo, hoping to better understand this outstanding RPC framework. I studied at Dubbo source code, written from scratch yourself a mini version of Dubbo.
Just the time when Ali and restart the Dubbo project, and became the Apache incubator project (when writing text has officially become Apache project). Dubbo new official website has a "Wanted: who's using dubbo" page, I also left their own information, to give a praise Dubbo point. Which contains the address of the mini version of the project in Dubbo.

In fact, is a very random act, I did not think the back story will happen. An hour later, I received an e-mail:

This is a letter from the head of the middleware team Dubbo mail. I was feeling quite unexpected, and very pleased. Middleware technology team has always been my opinion and influence are very strong team, if you can join the team, is a good opportunity.

So the next step is routine resume, the interview process. Ali's interview process next to Tucao, and it took almost two months, a total of five, it really is a protracted war. When the interview, the interviewer asked some questions about the mini Dubbo. The results also good, very lucky through the interview, officially joined the middleware Dubbo team. Then listen to my boss said, because the original is interested in my mini Dubbo project, only the interview invitation.

iris

mini version of the Dubbo project address: https://github.com/vangoleo/iris-java . I gave it the name iris.

iris is a lightweight, microkernel plus plug-in mechanism, Java-based RPC framework. Provide service registration, discovery, load balancing, support for API calls, Spring Integration and Spring Boot starter use.

It has the following features:

  • Network Communication: Netty4.
  • Registration Center: scalable, has supported etcd.
  • Dynamic Agent: byte-buddy.
  • Serialization: Protobuff (Protostuff).
  • It can be detached Spring, to provide API calls. Yourself achieving IoC container.
  • Integrated Spring, providing XML, Java configuration.
  • Provided Spring Boot Starter (the development of the project, Dubbo official does not support Spring Boot Starter).
  • SPI provides mechanisms to achieve microkernel architecture plus plug-ins. Scalable, developers can develop components for the iris, iris to be integrated into the form of a plug. Load plugin use another micro container frame see coco project. The project fork to Ali cooma.

Description: iris entirely my personal learning projects, small but perfectly formed, covers the basic functions of RPC framework. It just realized from 0-1, but from 1-100 There are many things to do.

how to use

iris supports the following ways:

  • Native API form, does not depend on Spring, Spring non-project can also be used.
  • Spring configuration, Spring and well integrated.
  • Spring Boot configuration provides a spring boot starter, with automatic configuration, quick start.

API use

Iris core code does not rely on Spring, Spring disengageable used.
The first step : start etcd registry
write an interface IHelloService

public interface IHelloService {
    String hello(String name);
}

Step Two : Write realization of a IHelloService

public class HelloService implements IHelloService {
    @Override
    public String hello(String name){
        return "Hello, " + name;
    }
}

The third step : Start the Server

IRegistry registry = new EtcdRegistry("http://127.0.0.1:2379");
RpcServer server = new RpcServer(registry)
        .port(2017)
        .exposeService(IHelloService.class,new HelloService());
server.run();

Step Four : Start the client

RpcClient client = new RpcClient(registry);
IHelloService helloService = client.create(IHelloService.class);
String s = helloService.hello("leo");
System.out.println(s);   // hello, leo

Step five : Try to stop the server
because the service provider does not, client error can not find provider
Step Six : Start the server
after Server starts, will go etcd registry registration services, client-side immediately work properly.

Spring configuration

The first step : writing service provider
service provider, using an interface custom annotation @Service to expose services through interfaceClass to the specified service. The notes are iris @Service provide, not Spring comment.

@Service(interfaceClass = IHelloService.class)
public class HelloService implements IHelloService {
    @Override
    public String hello(String name) throws Exception {
        return "hello" + name;
    }
}

Step Two : Write service consumer
service users, to refer to the remote service by @Reference, just like using a local SpringBean same. SpringBean package and Rpc behind calls transparent to the developer. Experience and Dubbo are the same.

public class Baz {

    @Reference(interfaceClass = IHelloService.class)
    private IHelloService helloService;

    public void hello(String name) throws Exception {
        System.out.println(helloService.hello(name));
    }
}

Step Three : Configure Spring Bean
configuration service provider, in this example uses XML configuration, can also be configured to use Java Code.

<bean id="registry" class="com.leibangzhu.iris.registry.EtcdRegistry">
        <constructor-arg name="registryAddress" value="http://127.0.0.1:2379"></constructor-arg>
    </bean>

    <bean id="server" class="com.leibangzhu.iris.server.RpcServer">
        <constructor-arg name="registry" ref="registry"></constructor-arg>
    </bean>

    <bean id="serviceAnnotationBeanPostProcessor" class="com.leibangzhu.iris.spring.ServiceAnnotationBeanPostProcessor"></bean>

<bean id="helloService" class="com.leibangzhu.iris.spring.HelloService"></bean>

Step Four : Configure the service to consumers, this example uses XML configuration, can also be configured to use Java Code.

<bean id="registry" class="com.leibangzhu.iris.registry.EtcdRegistry">
    <constructor-arg name="registryAddress" value="http://127.0.0.1:2379"></constructor-arg>
</bean>

<bean id="client" class="com.leibangzhu.iris.client.RpcClient">
    <constructor-arg name="registry" ref="registry"></constructor-arg>
</bean>

<bean id="referenceAnnotationBeanPostProcessor" class="com.leibangzhu.iris.spring.ReferenceAnnotationBeanPostProcessor"></bean>

<bean id="foo" class="com.leibangzhu.iris.spring.Baz"></bean>

Spring Boot Configuration

Using native Spring configuration is somewhat cumbersome, you can use Spring Boot to achieve better development experience.
The first step : writing service provider

@Service(interfaceClass = IHelloService.class)
public class HelloService implements IHelloService {
    @Override
    public String hello(String name) throws Exception {
        return "Hello, " + name + ", from com.leibangzhu.iris.springboot.HelloService";
    }
}

Step Two : Write service consumers

@Component
public class Foo {

    @Reference(interfaceClass = IHelloService.class)
    private IHelloService helloService;

    public String hello(String name) throws Exception {
        return helloService.hello(name);
    }
}

The third step : configuration service provider in application.properties file

iris.registry.address=http://127.0.0.1:2379

iris.server.enable=true
iris.server.port=2017
iris.annotation.package=com.leibangzhu.iris.springboot

Step Four : Configure service consumers in application.properties file

iris.registry.address=http://127.0.0.1:2379
iris.client.enable=true

When using SpringBoot, are not allowed to manually configure the associated spring bean, Iris provides a spring boot starter will automatically configure these spring bean.

Why the name iris

irisNamed after Van Gogh's painting Irises. I prefer painting, Van Gogh is my favorite painter, so with Van Gogh's Irises for the project name.

Why do you like Van Gogh?
In fact, I was not attracted painter Vincent van Gogh, but the pious, kind and fanatical Christian Van Gogh. I quote a circle of friends many years ago:

Recently every night before going to sleep listening to a Van Gogh biography. In fact, Van Gogh did not know before, glad you can hear the teacher of this Chiang Hsun Van Gogh biography, you can learn such a wonderful life. Lifetime Van Gogh sold only one painting had, or at a very low price, but after his death, his paintings became the greatest works of art. Why Van Gogh's sunflowers will burn so hot, a lot of people would say that because of his love of art, and some even say that because the Van Gogh visual disability. In fact, not the case. In his short 37 years of life, he actually lives only in the last four years, Van Gogh's life more important role as a religious identity is a painter, fanatical Christians. Van Gogh at the miners in Belgium, when faced with a group of ragged, Slim figured miners, Van Gogh looked disturbed, as a Christian, should not see this group of people and do nothing, as a Christian, you should see to the suffering of this world, and then be able to take it, that is the real salvation. Jesus came to earth not because of salvation for you, not because of salvation Jesus was only nailed it to the cross. If life is seen not part of salvation, the significance of the presence of Jesus Christ, what is it. He took off the ornate black robe, remove the white-towel, pick up a shovel, actually, and they go down into the pit together. Because the face of such a group of people, ornate sermons language can not help them, only to really feel their lives before they can help, please save these poor people. Van Gogh also chairs the church to tear down, to accommodate the injured miners in the mine, the whole part of their own food to the miners, with such a deep humanitarian concern of believers, the church received a dismissal letter, the church considered a priest should wear gorgeous gowns, speaking very high-sounding language sermons, Van Gogh did not uphold the dignity of the church. It was the biggest blow received in Van Gogh's life. When Van Gogh on the verge of despair, turned out to save his art is painting. What is the brush can depict such a warm sunflower Al, how is mental torture, let him cut off his ears, so much self-portrait of Van Gogh, indicating what? And what kind of a life can be in a mental hospital, was imprisoned in that little room, to create the greatest work of his life starry night. Van Gogh's last painting Catcher in the crow, whether predicted the end of his life. This is called the Vincent - William - Van Gogh's life.

My github account vangoleois actually vangogh(梵高)+ leo(我的英文名)portfolio.

Finally, attach some pictures of my own, I do not know if you can recognize them ^ _ ^

leehom

HUNTER

HUNTER

follow me

This article from the www.vangoleo.com release

Guess you like

Origin www.cnblogs.com/leiwei/p/11839018.html