lizining1231 opened a new pull request, #3689:
URL: https://github.com/apache/dubbo-go/pull/3689
### Description
Fixes #3688
`tools/benchmark`'s
[README_CN.md](file:///home/lizining/projects/dubbo-go/tools/benchmark/README_CN.md)
documents `dubbo-java` as a supported framework (`--framework` accepts
`dubbo-java`), but neither the client nor the two scripts implement it, and the
Java server itself has three blockers: protocol mismatch, build failure and
instant shutdown. The three way comparison (dubbo-go / grpc / dubbo-java) has
therefore always been missing the Java leg:
1. **Client rejects it**: `client/main.go` exits with `Invalid framework`
for `--framework dubbo-java`.
2. **Scripts don't support it**: `run_single.sh` / `run_all.sh` fall into
`Unsupported framework` /
`Skipping unknown framework` for `dubbo-java`.
3. **Protocol mismatch**: the Java server speaks the legacy `dubbo` protocol
with hand-written message
classes (package `org.apache.dubbo.benchmark`), while the Go client only
speaks `triple` + `protobuf`
and resolves `benchmark.BenchmarkService` — protocol, serialization and
service name all disagree,
so cross-language calls are impossible.
4. **Build failure**: `pom.xml` uses `${spring-boot.version}` as the
spring-boot parent version, which
Maven cannot resolve while parsing the parent POM (resolution-order
limitation), so the build fails.
5. **Instant shutdown**: the non-web Spring Boot app (`spring-boot-starter`)
exits right after `main()`
returns; no non-daemon thread keeps the JVM alive, so the port is never
listened on.
### Changes
**1. Build fixes: resolve the build failure and the artifact-name mismatch
with the docs**
`tools/benchmark/server/dubbo-java/pom.xml`:
- Drop the parent (`${spring-boot.version}` is unavailable during parent POM
resolution) and pin
version `2.7.18` on the starter dependency;
- Add the `dubbo-rpc-triple` dependency;
- Add `os-maven-plugin` and `protobuf-maven-plugin` (to generate Java
classes from
`benchmark.proto`);
- Set `<finalName>benchmark-dubbo-java</finalName>` so the artifact name
matches the README;
- Add `ServicesResourceTransformer` to the shade plugin to preserve Java SPI
files.
**2. Protocol migration: switch the server from the dubbo protocol to triple
and align the cross-language contract**
`tools/benchmark/server/dubbo-java/src/main/resources/application.properties`:
- `dubbo.protocol.name`: `dubbo` → `tri`;
- `dubbo.scan.base-packages`: `org.apache.dubbo.benchmark` → `benchmark`.
`tools/benchmark/server/dubbo-java/.../BenchmarkService.java` /
`BenchmarkServiceImpl.java`:
- `git mv` to the `benchmark` package so the service FQN is
`benchmark.BenchmarkService`, matching the service name the Go client requests;
- Replace message types with the protobuf-generated `BenchmarkProto`
(`UnaryCall` with a capital U is deliberate — it must match the Go-side method
name generated from the proto).
`tools/benchmark/server/dubbo-java/.../BenchmarkRequest.java` /
`BenchmarkResponse.java`:
- Delete. Hand-written POJOs cannot perform cross-language
(de)serialization; the protobuf-generated classes take over.
**3. Service registration & liveness: fix the unregistered service and the
instant exit**
`tools/benchmark/server/dubbo-java/.../BenchmarkServer.java`:
- `@EnableDubbo(scanBasePackages = "benchmark")` (the implementation has
moved to that package; default scanning cannot discover it);
- Block the main thread with a `CountDownLatch` (the non-web app exits right
after startup).
**4. Client & script integration: complete the end-to-end dubbo-java call
path**
`tools/benchmark/client/main.go`:
- Add a `dubbo-java` branch to `validFrameworks` and `createCaller` (reuse
the triple client, default port 20001);
- Restrict `dubbo-java` to `unary` call mode and `protobuf` serialization.
`tools/benchmark/scripts/run_single.sh / run_all.sh`:
- Add a `dubbo-java` branch: build with `mvn clean package -DskipTests` and
launch with `java -jar`;
- Add `dubbo-java` to the `FRAMEWORKS` array in `run_all.sh`.
### Test
| Test | Description |
| --- | --- |
| `mvn clean package -DskipTests` | Builds successfully, producing
`target/benchmark-dubbo-java.jar` |
| `java -jar` startup | Starts within seconds, listens on 20001, exports
`benchmark.BenchmarkService` (tri) |
| Cross-language smoke benchmark (1024B / 50 concurrency / 10s) | (29028
requests / 0 failures |
| SPI check (unpacked shaded jar) | 6 files under `META-INF/services`,
`org.apache.dubbo.rpc.Protocol` contains the `tri` entry |
### Validation
- Before fix: `--framework dubbo-java` exits with `Invalid framework`;
`run_single.sh dubbo-java` reports `Unsupported framework`; the Java server
fails to build and exits right after startup.
- After fix: the client routes to the Java provider over triple, the scripts
build and launch the Java server, and the end-to-end call succeeds with 100%
success rate.
### Checklist
- [x] I confirm the target branch is `develop`
- [x] I have run `make fmt` to format my code
- [x] I have run `make test` to run local tests
- [ ] I have added tests that prove my fix is effective or that my feature
works
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]