https://github.com/forezp/BootNettyRpc
一个采用Netty实现的RPC框架,适用于Spring Boot,Spring Cloud!
https://github.com/forezp/BootNettyRpc
Last synced: about 1 month ago
JSON representation
一个采用Netty实现的RPC框架,适用于Spring Boot,Spring Cloud!
- Host: GitHub
- URL: https://github.com/forezp/BootNettyRpc
- Owner: forezp
- License: apache-2.0
- Created: 2018-05-29T12:38:19.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-09-08T08:12:23.000Z (almost 5 years ago)
- Last Synced: 2026-02-01T07:58:02.546Z (5 months ago)
- Language: Java
- Homepage:
- Size: 181 KB
- Stars: 163
- Watchers: 13
- Forks: 72
- Open Issues: 2
-
Metadata Files:
- Readme: README-en.md
- License: LICENSE
Awesome Lists containing this project
- awesome-java - BootNettyRpc
README
# BootNettyRpc
[](https://github.com/forezp/BootNettyRpc/blob/master/LICENSE)
[](http://mvnrepository.com/artifact/io.github.forezp/boot-netty-rpc-core)
README: [English](https://github.com/forezp/BootNettyRpc/blob/master/README-en.md) | [中文](https://github.com/forezp/BootNettyRpc/blob/master/README.md)
## What's BootNettyRpc?
BootNettyRpc is a open resource of rpc with netty and spring boot !
## How to use?
--oops--@Deprecated--
### The server side
1.Add the dependency to your maven pom file.
```
io.github.forezp
boot-netty-rpc-core
1.0.3
```
2.Add @EnableNettyRpc annotation config to your project ,for example:
```
@SpringBootApplication
@EnableNettyRpc(basePackages = "com.forezp")
@RestController
public class ExampleRpcServerApplication {
public static void main(String[] args) {
SpringApplication.run( ExampleRpcServerApplication.class, args );
}
}
```
3. config the netty server port in your springboot config file,like application.yml:
```
server:
port: 7001
netty.server.name: server
netty.server.port: 6001
```
4. As a service provider ,expose the service to other client
```
@RpcClient(name = "server", rpcClz = "com.forezp.examplerpcserver.api.Greeting")
public interface IGreeting {
String sayHello(String name);
}
```
Implement the service:
```
@Service
public class Greeting implements IGreeting {
@Override
public String sayHello(String name) {
return "hi "+name;
}
}
```
### The Client Side
1.Add the dependency to your maven pom file.
```
io.github.forezp
boot-netty-rpc-core
1.0.3
```
2.Add @EnableNettyRpc annotation config to your project ,for example:
```
@SpringBootApplication
@EnableNettyRpc(basePackages = "com.forezp")
@RestController
public class ExampleRpcClientApplication {
public static void main(String[] args) {
SpringApplication.run( ExampleRpcClientApplication.class, args );
}
}
```
3. config the netty server port in your springboot config file,like application.yml:
```
netty:
clients:
- name: server
host: localhost
port: 6001
- name: server
host: localhost
port: 6001
```
4.comsume the provider service:
```
IGreeting invoker = (IGreeting) Invoker.invoke( IGreeting.class );
Object result = invoker.sayHello( "sww" );
```
## Contact Me
If there is any problem, let me know. My email: miles02@163.com