English | 中文
This example demonstrates the basic usage of dubbo-go as an RPC framework, and shows Dubbo-Go with Java Interoperability. Check Quick Start on our official website for detailed explanation.
Install protoc version3 Please refer to Protocol Buffer Compiler Installation.
Install protoc-gen-go and protoc-gen-triple Install the version of your choice of protoc-gen-go. here use the latest version as example:
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31
Install the latest version of protoc-gen-triple:
go install github.com/dubbogo/protoc-gen-go-triple/v3@v3.0.2
Generate stub code
Generate related stub code with protoc-gen-go and protoc-gen-go-triple:
protoc --go_out=. --go_opt=paths=source_relative --go-triple_out=. --go-triple_opt=paths=source_relative ./proto/greet.proto
Install Maven Maven
go run ./go-server/cmd/main.go
test server work as expected:
curl \ --header "Content-Type: application/json" \ --data '{"name": "Dubbo"}' \ http://localhost:20000/greet.GreetService/Greet
go run ./go-client/cmd/main.go
Build all Java modules from the root directory:
mvn clean compile
Run the Java server:
On Linux/Mac/Git Bash:
cd java-server mvn exec:java -Dexec.mainClass=org.example.server.JavaServerApp
On Windows PowerShell:
cd java-server mvn exec:java "-Dexec.mainClass=org.example.server.JavaServerApp"
Or use the provided script (Linux/Mac):
cd java-server ./run.sh
Test server works as expected:
curl \ --header "Content-Type: application/json" \ --data '{"name": "Dubbo"}' \ http://localhost:20000/greet.GreetService/Greet
Run the Java client:
On Linux/Mac/Git Bash:
cd java-client mvn exec:java -Dexec.mainClass=org.example.client.JavaClientApp
On Windows PowerShell:
cd java-client mvn exec:java "-Dexec.mainClass=org.example.client.JavaClientApp"
Or use the provided script (Linux/Mac):
cd java-client ./run.sh
Do NOT Start Go Server and Java Server at the Same Time. Both the Go server and Java server listen on the same port: 20000 and expose the same Triple service path:greet.GreetService/Greet