发布时间:2023-03-01 11:00
用的netty实现,没搭建注册中心,就是只有客户端和服务端,实现客户端远程调用服务端的sevice
仓库地址,https://github.com/wuhene/rpc-demo 结合代码看文章会更好理解,点个star支持下八~
<dependencies>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starterartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-configuration-processorartifactId>
<optional>trueoptional>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-aopartifactId>
dependency>
<dependency>
<groupId>io.nettygroupId>
<artifactId>netty-allartifactId>
dependency>
<dependency>
<groupId>ch.qos.logbackgroupId>
<artifactId>logback-classicartifactId>
dependency>
<dependency>
<groupId>org.projectlombokgroupId>
<artifactId>lombokartifactId>
dependency>
<dependency>
<groupId>com.alibabagroupId>
<artifactId>fastjsonartifactId>
<version>1.2.83version>
dependency>
dependencies>
所有的网络传输涉及到的消息对象都实现Message接口
这样抽象出来的作用是为了让每个rpc消息都能经过我们自定义的编/解码处理器
public interface Message {
public byte getType();
}