跳到主要内容

Dubbo JSON RPC Example

Note: This demo needs to run under go v1.17

Quick Start

step 1. Edit config file,add dubbo_json_rpc filter

jsonrpc.jpg

step 2. Compile and start layotto

go build -o layotto ./cmd/layotto
./layotto -c demo/rpc/dubbo_json_rpc/example.json

step 3. Start dubbo server

use dubbo-go-samples repo's example server.

git clone https://github.com/apache/dubbo-go-samples.git
cd dubbo-go-samples
git reset --hard f0d1e1076397a4736de080ffb16cd0963c8c2f9d

# start zookeeper
cd rpc/jsonrpc/go-server
docker-compose -f docker/docker-compose.yml up -d

# prepare to build dubbo server
cd cmd
export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"

Build dubbo server:

go build -o server .

Start dubbo server:

./server

step 4. call runtime InvokerService api.

go run demo/rpc/dubbo_json_rpc/dubbo_json_client/client.go -d '{"jsonrpc":"2.0","method":"GetUser","params":["A003"],"id":9527}'

jsonrpc.jpg

Next Step

If you are interested in the implementation principle, or want to extend some functions, you can read RPC design document