Protobuf

使用 IDL 定义服务

当前 Dubbo 的服务定义和具体的编程语言绑定,没有提供一种语言中立的服务描述格式,比如 Java 就是定义 Interface 接口,到了其他语言又得重新以另外的格式定义一遍。 2.7.5 版本通过支持 Protobuf IDL 实现了语言中立的服务定义。

日后,不论我们使用什么语言版本来开发 Dubbo 服务,都可以直接使用 IDL 定义如下服务,具体请参见示例

  1. syntax = "proto3";
  2. option java_multiple_files = true;
  3. option java_package = "org.apache.dubbo.demo";
  4. option java_outer_classname = "DemoServiceProto";
  5. option objc_class_prefix = "DEMOSRV";
  6. package demoservice;
  7. // The demo service definition.
  8. service DemoService {
  9. rpc SayHello (HelloRequest) returns (HelloReply) {}
  10. }
  11. // The request message containing the user's name.
  12. message HelloRequest {
  13. string name = 1;
  14. }
  15. // The response message containing the greetings
  16. message HelloReply {
  17. string message = 1;
  18. }

最后修改 September 21, 2021: Bug fix miss mialbox (#953) (57cf51b)