Skip to content

Conversation

@MrSibe
Copy link

@MrSibe MrSibe commented Dec 9, 2025

Overview

Adds Java client and server support to the async module, enabling cross-language async RPC calls between Java and Go over the Triple protocol.

What's New

  • Java Server: Async service implementation using CompletableFuture
  • Java Client: Async calls to Go server using CompletableFuture API
  • Go Client: Updated to call Java server by default
  • Documentation: Bilingual README with interoperability test scenarios

@MrSibe
Copy link
Author

MrSibe commented Dec 9, 2025

Original issue: apache/dubbo-go#3096

@MrSibe
Copy link
Author

MrSibe commented Dec 9, 2025

@Alanxtl @CAICAIIs PTAL

@MrSibe
Copy link
Author

MrSibe commented Dec 9, 2025

Do I need to modify the integrate test for Java Server and Client?

@Alanxtl
Copy link
Contributor

Alanxtl commented Dec 9, 2025

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

@MrSibe
Copy link
Author

MrSibe commented Dec 9, 2025

@Alanxtl
BTW, I saw this issue mentioned do not use time.Sleep in samples. Do I need to fix it in the next commit?

@Alanxtl
Copy link
Contributor

Alanxtl commented Dec 10, 2025

@Alanxtl BTW, I saw this issue mentioned do not use time.Sleep in samples. Do I need to fix it in the next commit?

不用,参考这个的实现加好panic判断行为是否符合预期就行了 #985

@Alanxtl
Copy link
Contributor

Alanxtl commented Dec 20, 2025

这个推进的怎么样了

@MrSibe
Copy link
Author

MrSibe commented Dec 20, 2025

这个推进的怎么样了

这个不是基本完成了吗?再review一下看看还有没有需要完善的地方?

Copy link
Contributor

@Alanxtl Alanxtl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

Copilot AI left a 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 user to org.apache.dubbo.samples.async.proto for Java compatibility
  • Adds Java server and client modules with Maven configuration for building protobuf stubs
  • Implements async RPC using CompletableFuture in 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.

Comment on lines +54 to +58
1. **Modify the Go client URL** in `go-client/cmd/main.go`:

```go
client.WithClientURL("tri://127.0.0.1:50051"),
```
Copy link

Copilot AI Dec 24, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

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.

Comment on lines +53 to +55
1. **修改 Go 客户端 URL**,在 `go-client/cmd/main.go` 中修改:

```go
Copy link

Copilot AI Dec 24, 2025

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.

Suggested change
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 服务端,请将上述行修改为:

Copilot uses AI. Check for mistakes.
Comment on lines +35 to +36
<properties>
<protobuf.version>3.21.7</protobuf.version>
Copy link

Copilot AI Dec 24, 2025

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.

Suggested change
<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>

Copilot uses AI. Check for mistakes.
Comment on lines +68 to +73
future2.whenComplete((response, throwable) -> {
if (throwable == null) {
System.out.println("sayHello completed");
}
latch2.countDown();
});
Copy link

Copilot AI Dec 24, 2025

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.

Copilot uses AI. Check for mistakes.
syntax = "proto3";

package user;
package org.apache.dubbo.samples.async.proto;
Copy link

Copilot AI Dec 24, 2025

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.

Suggested change
package org.apache.dubbo.samples.async.proto;
package user;

Copilot uses AI. Check for mistakes.
@AlexStocks
Copy link
Contributor

把 copilot 的review 结果看下哈

@AlexStocks
Copy link
Contributor

@MrSibe Please review the copilot's comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants