-
Notifications
You must be signed in to change notification settings - Fork 225
feat(generic): add generic call sample for both Dubbo and Triple protocols #1016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
9babfa4 to
da7f82d
Compare
|
…ocols Add comprehensive generic call examples demonstrating Go-Java interoperability using both Dubbo and Triple protocols with hessian2 serialization. Features: - Go client generic call examples for various parameter types - Java server supporting both Dubbo (port 20000) and Triple (port 50052) - Test cases covering basic types, collections, and POJO types
9fe8d23 to
3e4db86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the generic call sample to demonstrate both Dubbo and Triple protocol generic calls between Go and Java. The refactoring includes dual protocol support, project structure simplification, and a comprehensive test suite with 19 test cases.
Changes:
- Added dual protocol support (Dubbo on port 20000 and Triple on port 50052) with separate service groups
- Refactored project structure by removing redundant nested directories (java-server/java-server → java-server)
- Added comprehensive test coverage with 19 test cases and 2 benchmarks for generic calls
- Changed QueryUsers signature from List to User[] for consistency
Reviewed changes
Copilot reviewed 30 out of 38 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| go.mod | Added local replace directive for dubbo-go dependency (temporary) |
| generic/java-server/src/main/java/org/apache/dubbo/samples/ApiProvider.java | New dual protocol server implementation |
| generic/java-server/src/main/java/org/apache/dubbo/samples/User.java | Added User POJO class |
| generic/java-server/src/main/java/org/apache/dubbo/samples/Gender.java | Added Gender enum |
| generic/java-server/src/main/java/org/apache/dubbo/samples/UserProvider.java | Changed QueryUsers from List to array |
| generic/java-server/src/main/java/org/apache/dubbo/samples/UserProviderImpl.java | Updated QueryUsers implementation |
| generic/java-client/src/main/java/org/apache/dubbo/samples/ApiTripleConsumer.java | New Triple protocol consumer |
| generic/java-client/pom.xml | New client pom configuration |
| generic/go-server/cmd/server.go | Simplified server implementation |
| generic/go-server/pkg/user_provider.go | Added Invoke method for generic calls |
| generic/go-client/cmd/client.go | Refactored to test both protocols |
| generic/go-client/cmd/client_test.go | Added comprehensive test suite |
| generic/README.md | Updated documentation |
| generic/README_zh.md | Updated Chinese documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Start ZooKeeper: | ||
|
|
||
| ## Registry | ||
| ```bash | ||
| docker run -d --name zookeeper -p 2181:2181 zookeeper:3.8 | ||
| ``` |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both README files include instructions to start ZooKeeper in the "Prerequisites" section using docker, but the PR description states that ZooKeeper dependency was removed. The Prerequisites sections in both README.md and README_zh.md should be updated to reflect the direct connection mode that doesn't require ZooKeeper.
| ``` | ||
|
|
||
| ## 运行示例 | ||
| 客户端通过 ZooKeeper 发现服务,使用 `client.WithGenericType("true")` 进行泛化调用。 |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Chinese README states "客户端通过 ZooKeeper 发现服务" (client discovers service through ZooKeeper), but the client.go implementation uses direct URLs via client.WithURL() rather than ZooKeeper-based service discovery. The documentation should be updated to reflect the actual implementation.
| 客户端通过 ZooKeeper 发现服务,使用 `client.WithGenericType("true")` 进行泛化调用。 | |
| 客户端通过直连服务地址(例如使用 `client.WithURL("tri://127.0.0.1:50052")`)调用服务,并使用 `client.WithGenericType("true")` 进行泛化调用。 |
| ) | ||
|
|
||
| replace ( | ||
| dubbo.apache.org/dubbo-go/v3 => ../dubbo-go |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The local replace directive points to a relative path '../dubbo-go' which is a temporary development dependency. This should be removed before merging to production. The PR description mentions this depends on apache/dubbo-go#3154, so this replace directive should only be present during development/testing and removed once that PR is merged.
| - QueryUser(User user) | ||
| - QueryUsers(List<User> userObjectList) | ||
| - QueryAll() | ||
| - Do NOT start Go Server and Java Server at the same time. Both listen on port 50052. |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README states "Do NOT start Go Server and Java Server at the same time. Both listen on port 50052." However, according to the ApiProvider.java code, the Java server uses Dubbo protocol on port 20000 and Triple protocol on port 50052, while the Go server only uses port 50052. The documentation should clarify that the conflict is specifically for the Triple protocol port.
| - Do NOT start Go Server and Java Server at the same time. Both listen on port 50052. | |
| - Do NOT start the Go Server and the Java Server's Triple protocol endpoint on the same host at the same time, because both use port 50052 for Triple. |
| 启动 ZooKeeper: | ||
|
|
||
| - Docker 和 Docker Compose 用于运行 ZooKeeper 注册中心 | ||
| - Go 1.23+ 用于 Dubbo-Go 示例 | ||
| - Java 8+ 和 Maven 用于 Dubbo Java 示例 | ||
| ```bash | ||
| docker run -d --name zookeeper -p 2181:2181 zookeeper:3.8 | ||
| ``` |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Chinese README also includes ZooKeeper setup instructions in the Prerequisites section, which is inconsistent with the direct connection approach described in the PR. This section should be updated to match the removal of ZooKeeper dependency.
| dubbo.WithRegistry( | ||
| registry.WithZookeeper(), | ||
| registry.WithAddress(RegistryAddress), | ||
| registry.WithAddress("127.0.0.1:2181"), | ||
| ), |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Go server uses ZooKeeper registry (registry.WithZookeeper() and address "127.0.0.1:2181"), but the PR description states that ZooKeeper dependency was removed in favor of direct connection mode. The Java server in ApiProvider.java correctly uses direct export with registry address "N/A". The Go server should be updated to match this approach for consistency.
| - QueryUsers(List<User> userObjectList) | ||
| - QueryAll() | ||
| - Do NOT start Go Server and Java Server at the same time. Both listen on port 50052. | ||
| - Make sure ZooKeeper is running before starting the server or client. |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README.md states "Make sure ZooKeeper is running before starting the server or client," but the PR description indicates ZooKeeper dependency was removed in favor of direct connection mode. The updated Java server uses direct export (registry address "N/A"). This documentation is inconsistent with the implementation changes and should be updated.
| ```shell | ||
| # 启动 ZooKeeper 注册中心 | ||
| docker run -d --name zookeeper -p 2181:2181 zookeeper:3.4.14 | ||
| 服务端监听 `50052` 端口,并注册到 ZooKeeper。 |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Chinese README states the Go server "并注册到 ZooKeeper" (registers to ZooKeeper), but the PR description indicates ZooKeeper dependency was removed. While the current Go server implementation does still use ZooKeeper, according to the PR goals this should be changed to direct connection mode for consistency.
| @@ -0,0 +1,7 @@ | |||
| dubbo.application.name=generic-java-server | |||
| dubbo.registry.address=zookeeper://127.0.0.1:2181 | |||
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dubbo.properties file references a ZooKeeper registry address, but according to the PR description, ZooKeeper dependency was removed in favor of direct connection mode. This configuration file appears to be inconsistent with the new direct connection approach used in ApiProvider.java which sets registry address to "N/A".
| - QueryUsers(List<User> userObjectList) | ||
| - QueryAll() | ||
| - 不要同时启动 Go 服务端和 Java 服务端,它们都监听 50052 端口。 | ||
| - 启动服务端或客户端之前,请确保 ZooKeeper 正在运行。 |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Chinese documentation has the same issue as the English version - it states "启动服务端或客户端之前,请确保 ZooKeeper 正在运行" (Make sure ZooKeeper is running before starting the server or client), but this is inconsistent with the removal of ZooKeeper dependency mentioned in the PR description. The documentation should be updated to reflect the direct connection approach.
|
Please fix the ci failure and review the copilot's comment. |
What this PR does
This PR refactors and enhances the generic call sample to demonstrate both Dubbo protocol and Triple protocol generic calls between Go and Java.
Background
The existing generic sample only demonstrated Dubbo protocol generic call. With the new Triple protocol generic call support in dubbo-go (see apache/dubbo-go#3154), this sample needs to be updated to showcase both protocols.
Changes Overview
1. Dual Protocol Support
The sample now demonstrates generic call on both protocols:
dubbotriple2. Java Server Enhancement
Before: Single protocol, ZooKeeper dependency
After: Dual protocol, direct connection mode
3. Go Client Enhancement
Before: Only Dubbo protocol test
After: Tests both Dubbo and Triple protocols using new
GenericServiceAPI4. Comprehensive Test Suite
Added
client_test.gowith 19 test cases:Dubbo Protocol Tests (6 cases):
TestDubboGenericCall_StringArgTestDubboGenericCall_MultipleArgsTestDubboGenericCall_IntArgTestDubboGenericCall_NoArgsTestDubboGenericCall_ArrayArgTestDubboGenericCall_POJOArgTriple Protocol Tests (13 cases):
TestTripleGenericCall_StringArgTestTripleGenericCall_MultipleArgsTestTripleGenericCall_IntArgTestTripleGenericCall_NoArgsTestTripleGenericCall_ArrayArgTestTripleGenericCall_POJOArgTestTripleGenericCall_POJOArrayArgTestTripleGenericCall_MapResultTestTripleGenericCall_ListResultTestTripleGenericCall_EmptyArrayArgTestTripleGenericCall_NonExistentMethodTestTripleGenericCall_WithTimeoutTestTripleGenericCall_WithCancelledContextBenchmarks:
BenchmarkDubboGenericCallBenchmarkTripleGenericCall5. Project Structure Simplification
Before (nested directories):
After (flat structure):
6. Removed ZooKeeper Dependency
Files Changed
generic/java-server/src/.../ApiProvider.javageneric/java-client/src/.../ApiTripleConsumer.javageneric/go-client/cmd/client.gogeneric/go-client/cmd/client_test.gogeneric/go-server/cmd/server.gogeneric/go-server/pkg/user_provider.gogeneric/java-server/run.shgeneric/java-client/run.shgeneric/README.mdgeneric/README_zh.mdgeneric/java-*/java-*/generic/build/test.shHow to Test
1. Start Java Server
cd generic/java-server ./run.sh2. Run Go Client Tests
3. Or Run Go Client Manually
cd generic/go-client/cmd go run client.goTest Results
Related PRs
Signed-off-by: TsukiKage [email protected]