Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dinstone/jrpc
JRPC is a lightweight Java RPC framework.
https://github.com/dinstone/jrpc
discovery jrpc mina netty service-registry spring
Last synced: about 1 month ago
JSON representation
JRPC is a lightweight Java RPC framework.
- Host: GitHub
- URL: https://github.com/dinstone/jrpc
- Owner: dinstone
- Created: 2016-01-24T07:09:57.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-12-23T02:22:12.000Z (about 6 years ago)
- Last Synced: 2024-10-29T23:33:58.643Z (about 2 months ago)
- Topics: discovery, jrpc, mina, netty, service-registry, spring
- Language: Java
- Homepage:
- Size: 645 KB
- Stars: 58
- Watchers: 4
- Forks: 25
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license/ApacheV2.txt
Awesome Lists containing this project
README
# What
**JRPC** is a lightweight Java RPC framework. It enables quick and easy development of RPC applications. It greatly simplifies RPC programming.# Features
## Design
* Unified API for client and server
* Support a variety of serialization protocol at the same time - Jackson and Protobuff
* Layered architecture, including API layer, Proxy layer, Invoke layer, Protocol layer, Transport layer
* Pluggable service discovery - registry with Zookeeper
* The transport layer of the extensible implementation - mina, netty4, netty5## Ease of use
* Out of the box client-side and server-side API
* Spring integration friendly## Performance
* Efficient custom RPC protocol
* High-performance NIO socket frame support - mina and netty# Quick Start
select transport implement, add 'mina' or 'netty' dependency:
```xmlcom.dinstone.jrpc
jrpc-transport-mina
3.2.0```
or
```xmlcom.dinstone.jrpc
jrpc-transport-netty4
3.2.0```
if you need service registry and discovery, please add dependencies :
```xmlcom.dinstone.jrpc
jrpc-registry-zookeeper
3.2.0```
If you are integrated with Spring, please add dependencies :
```xmlcom.dinstone.jrpc
jrpc-spring
3.2.0```
# Example
For more details, please refer to the example project : [jrpc-example](https://github.com/dinstone/jrpc/tree/master/jrpc-example)## java programming by API
### export service:
```java
// setting endpoint config
EndpointConfig econfig = new EndpointConfig().setEndpointName("example-service-provider");// setting registry config
RegistryConfig rconfig = new RegistryConfig().setSchema("zookeeper").addProperty("zookeeper.node.list",
"localhost:2181");// setting transport config
TransportConfig tconfig = new TransportConfig().setSchema("mina").addProperty("rpc.handler.count", "2");Server server = null;
try {
ServerBuilder builder = new ServerBuilder().bind("localhost", 4444);
// build server and start it
server = builder.endpointConfig(econfig).registryConfig(rconfig).transportConfig(tconfig).build();
server.start();
// export service
server.exportService(HelloService.class, new HelloServiceImpl());System.in.read();
} finally {
if (server != null) {
server.stop();
}
}
```### import service:
```java
EndpointConfig endpointConfig = new EndpointConfig().setEndpointId("consumer-1")
.setEndpointName("example-service-consumer");RegistryConfig registryConfig = new RegistryConfig().setSchema("zookeeper").addProperty("zookeeper.node.list",
"localhost:2181");TransportConfig transportConfig = new TransportConfig().setSchema("netty").setConnectPoolSize(2);
Client client = new ClientBuilder().endpointConfig(endpointConfig).registryConfig(registryConfig)
.transportConfig(transportConfig).build();HelloService helloService = client.importService(HelloService.class);
helloService.sayHello("dinstone");client.destroy();
```## declarative programming by Spring
### export service:
```xml
```
### import service:
```xml
```
# Test Result
## JVM Parameter
```
-server -Xmx1g -Xms1g -Xmn712m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70
```## Benchmark Test
For more details, please refer to the benchmark project : [jrpc-benchmark](https://github.com/dinstone/jrpc/tree/master/jrpc-benchmark)