Coder Social home page Coder Social logo

nettyrpc's Introduction

NettyRpc

An RPC framework based on Netty, ZooKeeper and Spring
中文详情:Chinese Details

Features:

  • Simple code and framework
  • Non-blocking asynchronous call and Synchronous call support
  • Long lived persistent connection
  • High availability, load balance and failover
  • Service Discovery support by ZooKeeper

How to use

  1. Define an interface:

     public interface HelloService { 
     	String hello(String name); 
     	String hello(Person person);
     }
    
  2. Implement the interface with annotation @RpcService:

     @RpcService(HelloService.class)
     public class HelloServiceImpl implements HelloService {
     	@Override
     	public String hello(String name) {
     		return "Hello! " + name;
     	}
    
     	@Override
     	public String hello(Person person) {
     		return "Hello! " + person.getFirstName() + " " + person.getLastName();
     	}
     }
    
  3. Run the server with zookeeper:

     RpcBootstrap
    
  4. Run the client:

     ServiceDiscovery serviceDiscovery = new ServiceDiscovery("127.0.0.1:2181");
     final RpcClient rpcClient = new RpcClient(serviceDiscovery);
     // Sync call
     HelloService helloService = rpcClient.create(HelloService.class);
     String result = helloService.hello("World");
     // Async call
     IAsyncObjectProxy client = rpcClient.createAsync(HelloService.class);
     RPCFuture helloFuture = client.call("hello", "World");
     String result = (String) helloFuture.get(3000, TimeUnit.MILLISECONDS);
    

nettyrpc's People

Contributors

luxiaoxun avatar

Watchers

James Cloos avatar Joy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.