-
Notifications
You must be signed in to change notification settings - Fork 225
feat(async): Add Java interoperability with async RPC support #992
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
|
Original issue: apache/dubbo-go#3096 |
|
Do I need to modify the integrate test for Java Server and Client? |
@MrSibe thanks for your contribution, currently the intergration test doesn't test for java server and client, which we will support it in the future what we need now is to check the result for go server and client. Checking whether it works as we want |
|
@Alanxtl |
|
这个推进的怎么样了 |
这个不是基本完成了吗?再review一下看看还有没有需要完善的地方? |
Alanxtl
left a comment
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.
lgtm
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 adds Java client and server support to the async module, enabling cross-language async RPC calls between Java and Go over the Triple protocol. The implementation demonstrates bidirectional interoperability where Java clients can call Go servers and vice versa.
Key changes:
- Updates proto package name from
usertoorg.apache.dubbo.samples.async.protofor Java compatibility - Adds Java server and client modules with Maven configuration for building protobuf stubs
- Implements async RPC using
CompletableFuturein Java and existing Go async patterns
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| async/proto/user.proto | Updates package name to fully-qualified Java package and adds Java-specific options (java_package, java_multiple_files, java_outer_classname) for code generation |
| async/proto/user.triple.go | Regenerated Go stubs with updated service names reflecting the new proto package name |
| async/proto/user.pb.go | Regenerated Go protobuf code using newer protoc-gen-go version with structural changes |
| async/pom.xml | Parent POM defining shared dependencies, plugin configurations, and protobuf compilation setup |
| async/java-server/pom.xml | Java server module configuration with Dubbo and protobuf dependencies |
| async/java-server/src/main/java/org/apache/dubbo/samples/async/JavaAsyncServer.java | Java async server implementation using CompletableFuture with two service implementations (UserProvider and UserProviderV2) |
| async/java-server/run.sh | Shell script to build and run the Java server on port 50051 |
| async/java-client/pom.xml | Java client module configuration mirroring server dependencies |
| async/java-client/src/main/java/org/apache/dubbo/samples/async/JavaAsyncClient.java | Java async client implementation demonstrating async calls to Go server using CompletableFuture callbacks |
| async/java-client/run.sh | Shell script to build and run the Java client connecting to Go server on port 20000 |
| async/README.md | Updated documentation describing Java-Go interoperability test scenarios and setup instructions |
| async/README_zh.md | Chinese translation of updated documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 1. **Modify the Go client URL** in `go-client/cmd/main.go`: | ||
|
|
||
| ```go | ||
| client.WithClientURL("tri://127.0.0.1:50051"), | ||
| ``` |
Copilot
AI
Dec 24, 2025
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 documentation states that the Go client can be modified to connect to the Java server by changing the URL to "tri://127.0.0.1:50051", but the actual Go client code in go-client/cmd/main.go currently hardcodes "tri://127.0.0.1:20000". The README should clarify that this is the default configuration for Go-to-Go communication, and users need to manually change this line in the code to test Java interoperability as described.
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.
@MrSibe Please consider copilot's suggestion.
| 1. **修改 Go 客户端 URL**,在 `go-client/cmd/main.go` 中修改: | ||
|
|
||
| ```go |
Copilot
AI
Dec 24, 2025
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 documentation states that the Go client can be modified to connect to the Java server by changing the URL to "tri://127.0.0.1:50051", but the actual Go client code in go-client/cmd/main.go currently hardcodes "tri://127.0.0.1:20000". The README should clarify that this is the default configuration for Go-to-Go communication, and users need to manually change this line in the code to test Java interoperability as described.
| 1. **修改 Go 客户端 URL**,在 `go-client/cmd/main.go` 中修改: | |
| ```go | |
| 1. **修改 Go 客户端 URL**。Go 客户端默认配置为连接 Go 服务端(端口 `20000`),在 `go-client/cmd/main.go` 中通常如下: | |
| ```go | |
| client.WithClientURL("tri://127.0.0.1:20000"), |
为了让 Go 客户端连接到 Java 服务端,请将上述行修改为:
| <properties> | ||
| <protobuf.version>3.21.7</protobuf.version> |
Copilot
AI
Dec 24, 2025
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 protobuf version specified is 3.21.7, but the generated Go code (user.pb.go line 20) indicates it was generated with protoc v6.33.1. This version mismatch between the Maven configuration and the actual protoc version used could lead to inconsistencies. Consider updating the protobuf.version property to match the version of protoc that will be used to generate the code, or document which version should be used for consistency across Go and Java code generation.
| <properties> | |
| <protobuf.version>3.21.7</protobuf.version> | |
| <properties> | |
| <!-- Java-side protoc version used by protobuf-maven-plugin --> | |
| <protobuf.version>3.21.7</protobuf.version> | |
| <!-- Go-side protoc version used to generate user.pb.go (keep in sync with Go toolchain) --> | |
| <go.protoc.version>6.33.1</go.protoc.version> |
| future2.whenComplete((response, throwable) -> { | ||
| if (throwable == null) { | ||
| System.out.println("sayHello completed"); | ||
| } | ||
| latch2.countDown(); | ||
| }); |
Copilot
AI
Dec 24, 2025
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 error handling for the second async call (sayHelloAsync) is inconsistent with the first. The callback at line 68-73 only checks if throwable is null and prints "sayHello completed", but it doesn't handle or log the error case when throwable is not null. This means errors in the SayHello call will be silently ignored. Consider adding error handling similar to the first callback to ensure errors are properly logged.
| syntax = "proto3"; | ||
|
|
||
| package user; | ||
| package org.apache.dubbo.samples.async.proto; |
Copilot
AI
Dec 24, 2025
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 proto package name has been changed from "user" to "org.apache.dubbo.samples.async.proto" for Java interoperability. While this is intentional for cross-language compatibility, it's important to note that this is a breaking change for any existing clients or servers using the old package name. The change appears in the generated service names and should be coordinated across all implementations.
| package org.apache.dubbo.samples.async.proto; | |
| package user; |
|
把 copilot 的review 结果看下哈 |
|
@MrSibe Please review the copilot's comment. |
Overview
Adds Java client and server support to the
asyncmodule, enabling cross-language async RPC calls between Java and Go over the Triple protocol.What's New
CompletableFutureCompletableFutureAPI