2

JAVA分享篇(31)基础知识大总结

 1 year ago
source link: https://www.laiketui.com/104455.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

JAVA分享篇(31)基础知识大总结

行业动态 2023年1月13日 17:07 12

自定义传输协议
使用Netty框架可以自定义传输协议,如果定义了自定义传输协议,Netty会按照我们自定义的策略进行转换,所以我们这里有一个类来自定义传输协议。代码如下:

package cn.itsource.protocol;

import lombok.Data;

import java.io.Serializable;

/**
* 自定义传输协议
*/
@Data
public class MyInvokerProtocol implements Serializable {

private String className;//类名
private String methodName;//函数名称
private Class<?>[] parames;//形参列表
private Object[] values;//实参列表

}
测试
测试远程调用,我们首先启动服务端启动类RpcServer。控制台出现如下信息表示启动成功。

cn.itsource.provider.RpcServer x
ugger Console
D:\devolp\java\jdk1.8.0_131\bin\java.exe
Connected to the target VM, address:’127.0.0.1:8102′, transport: ‘socket’ RPC start success, listen port is :8082 !!
免责声明:部分文章信息来源于网络以及客户意见反馈,本站只负责对文章进行整理、排版、编辑,出于传递更多信息之目的,并不意味着赞同其观点或证实其内容的真实性,如本站文章和转稿涉及版权等问题,请作者在及时联系本站,我们会尽快联系您处理


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK