Rpc-Agent介绍
Rpc Agent is a framework, with which you can develop an agent server for a RPC framework.
Quick Start
Rpc Agent provide a simple demo for a quick start.
How to Build
Make sure maven has been installed on your machine
Run
mvn clean package
to build this projectat the last, if success, you will see message like this
1 | [INFO] Reactor Summary for rpc-agent-parent 1.0-SNAPSHOT: |
rpc-agent-simple is a demo, and the target jar file is rpc-agent-simple-1.0-SNAPSHOT-jar-with-dependencies.jar
, you can rename it to rpc-agent-simple.jar
.
How to use
Run java -jar rpc-agent-simple.jar -h
to see what you can do with this tool
1 | Usage: java -jar rpc-agent-simple.jar [options] |
Run java -jar rpc-agent-simple.jar -d
to export demo config file
1 | write config file: demo.json |
Open demo.json
to see the config format
1 | { |
Run in Client Mode
Run command java -jar rpc-agent-simple.jar -f demo.json
to start a remote call
1 | java -jar rpc-agent-simple.jar -f demo.json |
Run in Server Mode
Run command java -jar rpc-agent-simple.jar -s
to start agent server, and you can use -l
option to use loopback address, use -p
option to set server port.
If server started success, it will log to console like this
1 | server started, agent path: [localhost:8080/agent] |
then you can start a remote call with Postman or other tools
How to develop
See rpc-agent-simple module
1 | ├── java |
RpcConfigParser
: parse request config toRpcRequest
andInvokerConfig
RpcRequest
: the parameter for a remote callInvokerConfig
: the remote serverInvokerBuilder
: to bulid a concreteInvoker
, for example, aInvoker
for dubbo
As you see, what you need to do is provide a RpcConfigParser
and a Invoker
with InvokerBuilder
, then you can register all this with SPI file com.gorden5566.rpc.agent.core.spi.InvokerBuilder
and com.gorden5566.rpc.agent.core.spi.RpcConfigParser
.
At last, you can custom title or vendor in pom.xml
1 | <build> |
Reference
- 2019-11-20
javaagent 使用 jar 文件格式进行打包,通过 jar 文件里的 manifest 清单文件指定被加载的类,用于启动 agent。
- 2017-06-20
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick Start
Create a new post
1
$ hexo new "My New Post"
- 2022-01-07
兴趣是最好的老师,当你对一件事情感兴趣的时候,你就更容易长久地坚持下去,从而达到一个更高的高度,或许还能够取得意想不到的效果。接下来我会从实现一个 echo server 开始 netty 的探索旅程,如果你也对 netty 感兴趣,那么我们就开始吧。
- 2017-12-03
本次编译使用的系统是
macOS High Sierra
,版本为10.13.1
。使用的 jdk 是Oracle JDK
,版本为1.7.0_79
。1
2
3java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode) - 2021-04-08
最近遇到了一次诡异的
NoSuchMethodError
错误,通常情况下遇到这个报错,大概率是类加载冲突导致的,然而这次的情况却不大一样。