Ants gold dress Java RPC open-source framework -SOFARPC

SOFARPC Profile

SOFARPC is a highly scalable, high performance, production-level Java RPC frame. Ants gold dress SOFARPC has experienced more than 10 years and five generations version of development. SOFARPC committed RPC calls between the simplified application for application to facilitate transparent, stable and efficient remote service call-point program. In order to facilitate the users and developers with enhanced functionality, SOFARPC abstract model provides a rich and extensible interface, including filters, routing, load balancing and so on. While providing a wealth of micro-governance programs around SOFARPC service framework and its peripheral components.

Features

  • Transparent, high-performance remote service call
  • Support for multiple service routing and load balancing strategy
  • It supports a variety of integrated registry
  • Support for multiple protocols, including Bolt, Rest, Dubbo, etc.
  • It supports synchronization, one-way, correction, generalization and other ways to call
  • Support fault-tolerant cluster, warm service, automatic fault isolation
  • Powerful extensions can be extended as needed for each functional block

Development Environment Support

1, the compiler requires JDK 7 and above, Maven 3.2.5 and above
2, operating requirements JDK 6 and above

Fundamental

SOFARPC
1. When an application starts SOFARPC, and if we find the current application needs to publish RPC service, then SOFARPC these services will register to the service registry. Service points in FIG Registry.
2, when referring to this service SOFARPC application starts, it will subscribe to the service center to register metadata information corresponding service. After the service registry received subscription requests, metadata list will be pushed to the publisher of real-time quote service side. As shown in point Registry Reference.
3. When the service reference side to get an address, you can select from address to initiate a call. As shown in Reference point Service.

Quick Start

Demonstrates how to apply SOFARPC publishing and reference services. This example will start listening on a port and publish a service, client service direct reference to the call in local analog server.

The first step: create a new Maven project, and the introduction of SOFARPC dependence
<dependency>
    <groupId>com.alipay.sofa</groupId>
    <artifactId>sofa-rpc-all</artifactId>
    <version>5.5.3</version>
</dependency>

Version Download: https://mvnrepository.com/artifact/com.alipay.sofa/sofa-rpc-all/

Step Two: Write server realize

Creating an interface HelloService

/**
 * Quick Start demo interface
 */
public interface HelloService {
    String sayHello(String string);
}

Creating interface HelloServiceImpl

/**
 * Quick Start demo implement
 */
public class HelloServiceImpl implements HelloService {
    @Override
    public String sayHello(String string) {
        System.out.println("Server receive: " + string);
        return "hello " + string + " !";
    }
}

Writing server code

/**
 * Quick Start Server
 */
public class QuickStartServer {

    public static void main(String[] args) {
        ServerConfig serverConfig = new ServerConfig()
                .setProtocol("bolt") // 设置一个协议,默认bolt
                .setPort(12200) // 设置一个端口,默认12200
                .setDaemon(false); // 非守护线程

        ProviderConfig<HelloService> providerConfig = new ProviderConfig<HelloService>()
                .setInterfaceId(HelloService.class.getName()) // 指定接口
                .setRef(new HelloServiceImpl()) // 指定实现
                .setServer(serverConfig); // 指定服务端

        providerConfig.export(); // 发布服务
    }
}

Write client implementation

/**
 * Quick Start client
 */
public class QuickStartClient {
    public static void main(String[] args) {
        ConsumerConfig<HelloService> consumerConfig = new ConsumerConfig<HelloService>()
            .setInterfaceId(HelloService.class.getName()) // 指定接口
            .setProtocol("bolt") // 指定协议
            .setDirectUrl("bolt://127.0.0.1:12200"); // 指定直连地址
        // 生成代理类
        HelloService helloService = consumerConfig.refer();
        while (true) {
            System.out.println(helloService.sayHello("world"));
            try {
                Thread.sleep(2000);
            } catch (Exception e) {
            }
        }
    }
}

Runs
respectively start the server and client to observe the operating results.
The print server:

Server receive: world

The client will print:

hello world !

summary

Is not found, the difference SOFA-RPC and Dubbo, Motan not much. Dubbo exist as a full-service governance, and SOFA-RPC is only a lightweight RPC framework, based on the framework of the transformation of HSF, to provide more comprehensive, powerful, diverse RPC programming API.

The latest version v5.5.3 publish content

SOFARPC v5.5.3 This is a Bug Fix version 5.5.x version currently being used to encourage users to upgrade.
1, compatibility
is no incompatibility

3, BUG repair

  • Repair Special Scenes route duplication
  • Tracer compatible sample identification
  • Repair generalization call retry again question

Follow us

Contributors

More exciting content can focus on "IT real coalition" public congregation No. Oh ~ ~ ~

Here Insert Picture Description

Guess you like

Origin blog.csdn.net/zhenghhgz/article/details/90437546