This is an automated email from the ASF dual-hosted git repository.

Alanxtl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new 3945883ad fix(benchmark): Add support for dubbo-java benchmark (#3689)
3945883ad is described below

commit 3945883ad5c8e726143e08ea6f27266d1e25e163
Author: Li Zining <[email protected]>
AuthorDate: Thu Aug 20 13:11:03 2026 +0800

    fix(benchmark): Add support for dubbo-java benchmark (#3689)
    
    * build(tool): fix dubbo-java pom to compile and package
    
    The dubbo-java benchmark server failed to build because the spring-boot
    parent version referenced ${spring-boot.version}, which Maven cannot
    resolve during parent POM resolution. Replace the parent with an
    explicit 2.7.18 version, and add the triple rpc + protobuf build
    plugins, <finalName> alignment with README_CN, and a
    ServicesResourceTransformer to preserve Java SPI files after shading.
    
    Fixes #3688
    
    Signed-off-by: lizining <[email protected]>
    
    * feat(tool): migrate dubbo-java server to triple protocol
    
    The server spoke the legacy dubbo protocol with hand-written message
    classes, so the Go benchmark client (triple + protobuf only, resolving
    benchmark.BenchmarkService) could never reach it. Switch to triple:
    move the service into the benchmark package (git mv, keeping history),
    use protobuf-generated BenchmarkProto messages, and keep UnaryCall
    (capital U) to match the method name generated on the Go side.
    
    Signed-off-by: lizining <[email protected]>
    
    * fix(tool): keep dubbo-java server alive and scan benchmark package
    
    Two startup issues blocked benchmarking the Java server: the non-web
    Spring Boot app exited right after main() returned (port 20001 never
    listened), and @EnableDubbo's default scan missed the implementation
    after it moved to the benchmark package. Block the main thread with a
    CountDownLatch and point @EnableDubbo at the benchmark package.
    
    Signed-off-by: lizining <[email protected]>
    
    * feat(tool): support dubbo-java in benchmark client and scripts
    
    README_CN documents dubbo-java as a supported framework, but neither
    the client nor the scripts implemented it, so the Java server could
    never be benchmarked end-to-end. Accept --framework dubbo-java in the
    client (triple client, port 20001, unary + protobuf only) and add
    dubbo-java branches to run_single.sh / run_all.sh (mvn package +
    java -jar).
    
    Signed-off-by: lizining <[email protected]>
    
    ---------
    
    Signed-off-by: lizining <[email protected]>
---
 tools/benchmark/client/main.go                     | 33 ++++++++++------
 tools/benchmark/scripts/run_all.sh                 | 13 ++++++-
 tools/benchmark/scripts/run_single.sh              |  9 +++++
 tools/benchmark/server/dubbo-java/pom.xml          | 45 ++++++++++++++++++----
 .../dubbo => }/benchmark/BenchmarkService.java     |  6 ++-
 .../dubbo => }/benchmark/BenchmarkServiceImpl.java |  9 +++--
 .../apache/dubbo/benchmark/BenchmarkRequest.java   | 37 ------------------
 .../apache/dubbo/benchmark/BenchmarkResponse.java  | 37 ------------------
 .../apache/dubbo/benchmark/BenchmarkServer.java    |  8 +++-
 .../src/main/resources/application.properties      |  4 +-
 10 files changed, 99 insertions(+), 102 deletions(-)

diff --git a/tools/benchmark/client/main.go b/tools/benchmark/client/main.go
index f6b100f58..163ca6815 100644
--- a/tools/benchmark/client/main.go
+++ b/tools/benchmark/client/main.go
@@ -43,17 +43,18 @@ import (
 )
 
 const (
-       FrameworkDubboGo = "dubbo-go"
-       FrameworkGRPC    = "grpc"
-       Separator        = "========================================"
-       MaxPayloadSize   = 16 * 1024 * 1024 // 16MB
-       MinPayloadSize   = 1
-       MinConcurrency   = 1
-       MaxConcurrency   = 10000
+       FrameworkDubboGo   = "dubbo-go"
+       FrameworkDubboJava = "dubbo-java"
+       FrameworkGRPC      = "grpc"
+       Separator          = "========================================"
+       MaxPayloadSize     = 16 * 1024 * 1024 // 16MB
+       MinPayloadSize     = 1
+       MinConcurrency     = 1
+       MaxConcurrency     = 10000
 )
 
 var (
-       framework      = flag.String("framework", FrameworkDubboGo, "Framework: 
dubbo-go / grpc")
+       framework      = flag.String("framework", FrameworkDubboGo, "Framework: 
dubbo-go / dubbo-java / grpc")
        payloadSize    = flag.Int("payload", 1024, "Payload size (bytes)")
        serialization  = flag.String("serialization", "protobuf", 
"Serialization protocol: hessian2 / protobuf / msgpack")
        compression    = flag.String("compression", "none", "Compression 
strategy: none / default / fastest")
@@ -119,7 +120,7 @@ type BenchmarkResult struct {
 }
 
 var (
-       validFrameworks     = map[string]bool{FrameworkDubboGo: true, 
FrameworkGRPC: true}
+       validFrameworks     = map[string]bool{FrameworkDubboGo: true, 
FrameworkDubboJava: true, FrameworkGRPC: true}
        validSerializations = map[string]bool{"hessian2": true, "protobuf": 
true, "msgpack": true}
        validCompressions   = map[string]bool{"none": true, "default": true, 
"fastest": true}
        validCallModes      = map[string]bool{"unary": true, "streaming": true}
@@ -127,7 +128,7 @@ var (
 
 func validateParams() {
        if !validFrameworks[*framework] {
-               logger.Fatalf("Invalid framework: %s. Valid values: dubbo-go, 
grpc", *framework)
+               logger.Fatalf("Invalid framework: %s. Valid values: dubbo-go, 
dubbo-java, grpc", *framework)
        }
 
        if *payloadSize < MinPayloadSize || *payloadSize > MaxPayloadSize {
@@ -150,6 +151,14 @@ func validateParams() {
                logger.Fatalf("Invalid call mode: %s. Valid values: unary, 
streaming", *callMode)
        }
 
+       if *framework == FrameworkDubboJava && *callMode != "unary" {
+               logger.Fatalf("Invalid call mode for dubbo-java: %s. Only unary 
is supported", *callMode)
+       }
+
+       if *framework == FrameworkDubboJava && *serialization != "protobuf" {
+               logger.Fatalf("Invalid serialization for dubbo-java: %s. Only 
protobuf is supported", *serialization)
+       }
+
        if _, err := time.ParseDuration(*testDuration); err != nil {
                logger.Fatalf("Invalid test duration: %v", err)
        }
@@ -268,6 +277,8 @@ func createCaller(data []byte) (Caller, error) {
                switch *framework {
                case FrameworkDubboGo:
                        addr = "127.0.0.1:20000"
+               case FrameworkDubboJava:
+                       addr = "127.0.0.1:20001"
                case FrameworkGRPC:
                        addr = "127.0.0.1:50051"
                default:
@@ -276,7 +287,7 @@ func createCaller(data []byte) (Caller, error) {
        }
 
        switch *framework {
-       case FrameworkDubboGo:
+       case FrameworkDubboGo, FrameworkDubboJava:
                return clients.NewDubboGoClient(addr, *serialization, 
*compression, *callMode, data)
        case FrameworkGRPC:
                return clients.NewGrpcClient(addr, *callMode, data)
diff --git a/tools/benchmark/scripts/run_all.sh 
b/tools/benchmark/scripts/run_all.sh
index bdcc538f6..0dcce8d9e 100755
--- a/tools/benchmark/scripts/run_all.sh
+++ b/tools/benchmark/scripts/run_all.sh
@@ -75,6 +75,10 @@ echo "[INFO] Compiling gRPC server..."
 cd "$BASE_DIR/server/grpc"
 go build -o benchmark-grpc main.go
 
+echo "[INFO] Compiling Dubbo-Java server..."
+cd "$BASE_DIR/server/dubbo-java"
+mvn clean package -DskipTests -q
+
 echo ""
 echo "[INFO] Compiling benchmark client..."
 cd "$BASE_DIR/client"
@@ -83,7 +87,7 @@ go build -o benchmark-client main.go
 echo ""
 echo "[INFO] Starting full benchmark suite..."
 
-FRAMEWORKS=("dubbo-go" "grpc")
+FRAMEWORKS=("dubbo-go" "grpc" "dubbo-java")
 PAYLOADS=("128" "1024" "16384" "1048576")
 SERIALIZATIONS=("protobuf")
 COMPRESSIONS=("none")
@@ -103,6 +107,10 @@ for framework in "${FRAMEWORKS[@]}"; do
             SERVER_BIN="$BASE_DIR/server/grpc/benchmark-grpc"
             SERVER_PORT=50051
             ;;
+        dubbo-java)
+            
SERVER_BIN="$BASE_DIR/server/dubbo-java/target/benchmark-dubbo-java.jar"
+            SERVER_PORT=20001
+            ;;
         *)
             echo "[WARNING] Skipping unknown framework: $framework"
             continue
@@ -129,6 +137,9 @@ for framework in "${FRAMEWORKS[@]}"; do
                             grpc)
                                 "$SERVER_BIN" --port "$SERVER_PORT" > 
"$LOG_FILE.server.log" 2>&1 &
                                 ;;
+                            dubbo-java)
+                                java -jar "$SERVER_BIN" > 
"$LOG_FILE.server.log" 2>&1 &
+                                ;;
                             *)
                                 echo "[ERROR] Unsupported framework: 
$framework"
                                 exit 1
diff --git a/tools/benchmark/scripts/run_single.sh 
b/tools/benchmark/scripts/run_single.sh
index f302cb29f..6a51b7917 100755
--- a/tools/benchmark/scripts/run_single.sh
+++ b/tools/benchmark/scripts/run_single.sh
@@ -83,6 +83,12 @@ case "$FRAMEWORK" in
         SERVER_BIN="$BASE_DIR/server/grpc/benchmark-grpc"
         SERVER_PORT=50051
         ;;
+    dubbo-java)
+        cd "$BASE_DIR/server/dubbo-java"
+        mvn clean package -DskipTests -q
+        
SERVER_BIN="$BASE_DIR/server/dubbo-java/target/benchmark-dubbo-java.jar"
+        SERVER_PORT=20001
+        ;;
     *)
         echo "[ERROR] Unsupported framework: $FRAMEWORK"
         exit 1
@@ -104,6 +110,9 @@ case "$FRAMEWORK" in
     grpc)
         "$SERVER_BIN" --port "$SERVER_PORT" > "$LOG_FILE.server.log" 2>&1 &
         ;;
+    dubbo-java)
+        java -jar "$SERVER_BIN" > "$LOG_FILE.server.log" 2>&1 &
+        ;;
     *)
         echo "[ERROR] Unsupported framework: $FRAMEWORK"
         exit 1
diff --git a/tools/benchmark/server/dubbo-java/pom.xml 
b/tools/benchmark/server/dubbo-java/pom.xml
index 5f9b54795..9669be419 100644
--- a/tools/benchmark/server/dubbo-java/pom.xml
+++ b/tools/benchmark/server/dubbo-java/pom.xml
@@ -34,17 +34,11 @@
         <spring-boot.version>2.7.18</spring-boot.version>
     </properties>
 
-    <parent>
-        <groupId>org.springframework.boot</groupId>
-        <artifactId>spring-boot-starter-parent</artifactId>
-        <version>${spring-boot.version}</version>
-        <relativePath/>
-    </parent>
-
     <dependencies>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter</artifactId>
+            <version>${spring-boot.version}</version>
         </dependency>
 
         <dependency>
@@ -59,6 +53,12 @@
             <version>${dubbo.version}</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-rpc-triple</artifactId>
+            <version>${dubbo.version}</version>
+        </dependency>
+
         <dependency>
             <groupId>com.google.protobuf</groupId>
             <artifactId>protobuf-java</artifactId>
@@ -74,7 +74,37 @@
     </dependencies>
 
     <build>
+        <finalName>benchmark-dubbo-java</finalName>
         <plugins>
+            <plugin>
+                <groupId>kr.motd.maven</groupId>
+                <artifactId>os-maven-plugin</artifactId>
+                <version>1.7.1</version>
+                <executions>
+                    <execution>
+                        <phase>initialize</phase>
+                        <goals>
+                            <goal>detect</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.xolstice.maven.plugins</groupId>
+                <artifactId>protobuf-maven-plugin</artifactId>
+                <version>0.6.1</version>
+                <configuration>
+                    
<protoSourceRoot>${project.basedir}/../../proto</protoSourceRoot>
+                    
<protocArtifact>com.google.protobuf:protoc:3.21.7:exe:${os.detected.classifier}</protocArtifact>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>compile</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
@@ -99,6 +129,7 @@
                                 <transformer 
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                     
<mainClass>org.apache.dubbo.benchmark.BenchmarkServer</mainClass>
                                 </transformer>
+                                <transformer 
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                             </transformers>
                         </configuration>
                     </execution>
diff --git 
a/tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkService.java
 
b/tools/benchmark/server/dubbo-java/src/main/java/benchmark/BenchmarkService.java
similarity index 84%
rename from 
tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkService.java
rename to 
tools/benchmark/server/dubbo-java/src/main/java/benchmark/BenchmarkService.java
index ca846b06c..92e968eaa 100644
--- 
a/tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkService.java
+++ 
b/tools/benchmark/server/dubbo-java/src/main/java/benchmark/BenchmarkService.java
@@ -15,8 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.dubbo.benchmark;
+package benchmark;
+
+import org.apache.dubbo.benchmark.BenchmarkProto;
 
 public interface BenchmarkService {
-    BenchmarkResponse unaryCall(BenchmarkRequest request);
+    BenchmarkProto.BenchmarkResponse UnaryCall(BenchmarkProto.BenchmarkRequest 
request);
 }
diff --git 
a/tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkServiceImpl.java
 
b/tools/benchmark/server/dubbo-java/src/main/java/benchmark/BenchmarkServiceImpl.java
similarity index 76%
rename from 
tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkServiceImpl.java
rename to 
tools/benchmark/server/dubbo-java/src/main/java/benchmark/BenchmarkServiceImpl.java
index bf425a96f..3c62cb61f 100644
--- 
a/tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkServiceImpl.java
+++ 
b/tools/benchmark/server/dubbo-java/src/main/java/benchmark/BenchmarkServiceImpl.java
@@ -15,15 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.dubbo.benchmark;
+package benchmark;
 
+import org.apache.dubbo.benchmark.BenchmarkProto;
 import org.apache.dubbo.config.annotation.DubboService;
 
 @DubboService
 public class BenchmarkServiceImpl implements BenchmarkService {
 
     @Override
-    public BenchmarkResponse unaryCall(BenchmarkRequest request) {
-        return new BenchmarkResponse(request.getPayload());
+    public BenchmarkProto.BenchmarkResponse 
UnaryCall(BenchmarkProto.BenchmarkRequest request) {
+        return BenchmarkProto.BenchmarkResponse.newBuilder()
+                .setPayload(request.getPayload())
+                .build();
     }
 }
diff --git 
a/tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkRequest.java
 
b/tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkRequest.java
deleted file mode 100644
index cddab5611..000000000
--- 
a/tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkRequest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dubbo.benchmark;
-
-public class BenchmarkRequest {
-    private byte[] payload;
-
-    public BenchmarkRequest() {
-    }
-
-    public BenchmarkRequest(byte[] payload) {
-        this.payload = payload;
-    }
-
-    public byte[] getPayload() {
-        return payload;
-    }
-
-    public void setPayload(byte[] payload) {
-        this.payload = payload;
-    }
-}
diff --git 
a/tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkResponse.java
 
b/tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkResponse.java
deleted file mode 100644
index 15c3e6be9..000000000
--- 
a/tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkResponse.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dubbo.benchmark;
-
-public class BenchmarkResponse {
-    private byte[] payload;
-
-    public BenchmarkResponse() {
-    }
-
-    public BenchmarkResponse(byte[] payload) {
-        this.payload = payload;
-    }
-
-    public byte[] getPayload() {
-        return payload;
-    }
-
-    public void setPayload(byte[] payload) {
-        this.payload = payload;
-    }
-}
diff --git 
a/tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkServer.java
 
b/tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkServer.java
index 816fb8efe..9c460a460 100644
--- 
a/tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkServer.java
+++ 
b/tools/benchmark/server/dubbo-java/src/main/java/org/apache/dubbo/benchmark/BenchmarkServer.java
@@ -23,13 +23,15 @@ import org.slf4j.LoggerFactory;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 
+import java.util.concurrent.CountDownLatch;
+
 @SpringBootApplication
-@EnableDubbo
+@EnableDubbo(scanBasePackages = "benchmark")
 public class BenchmarkServer {
 
     private static final Logger logger = 
LoggerFactory.getLogger(BenchmarkServer.class);
 
-    public static void main(String[] args) {
+    public static void main(String[] args) throws InterruptedException {
         logger.info("========================================");
         logger.info("    Dubbo-Java Benchmark Server");
         logger.info("========================================");
@@ -37,5 +39,7 @@ public class BenchmarkServer {
         logger.info("Server listening on: 127.0.0.1:20001");
         SpringApplication.run(BenchmarkServer.class, args);
         logger.info("Server started, waiting for requests...");
+        // Keep the non-web Spring Boot app alive after startup.
+        new CountDownLatch(1).await();
     }
 }
diff --git 
a/tools/benchmark/server/dubbo-java/src/main/resources/application.properties 
b/tools/benchmark/server/dubbo-java/src/main/resources/application.properties
index 37f11013e..c130c9aae 100644
--- 
a/tools/benchmark/server/dubbo-java/src/main/resources/application.properties
+++ 
b/tools/benchmark/server/dubbo-java/src/main/resources/application.properties
@@ -1,7 +1,7 @@
 server.port=20001
 
 dubbo.application.name=dubbo-java-benchmark
-dubbo.protocol.name=dubbo
+dubbo.protocol.name=tri
 dubbo.protocol.port=20001
 dubbo.registry.address=N/A
-dubbo.scan.base-packages=org.apache.dubbo.benchmark
+dubbo.scan.base-packages=benchmark

Reply via email to