Thrift 協定
功能說明
dubbo 目前支援的 thrift 協定是 thrift 原生協定的擴充,在原生協定的基礎上增加了一些額外的 header 資訊,例如服務名稱、魔術數字等等。2.3.0
及以上版本都支援。
Thrift 是 Facebook 捐贈給 Apache 的一個 RPC 框架。
使用 dubbo thrift 協定也需要使用 thrift 的 idl 編譯器編譯產生對應的 Java 程式碼,後續版本會在這方面做一些增強。
使用場景
適用於 SOA 標準的 RPC 框架。
使用方法
依賴關係
從 Dubbo 3 開始,Thrift 協定不再內嵌於 Dubbo 中,需要單獨引入一個獨立的 模組。
<dependency>
<groupId>org.apache.dubbo.extensions</groupId>
<artifactId>dubbo-rpc-native-thrift</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.8.0</version>
</dependency>
所有服務共用一個埠
與原生 Thrift 不相容
<dubbo:protocol name="thrift" port="3030" />
[dubbo 專案中的範例程式碼](https://github.com/apache/dubbo/tree/master/dubbo-rpc/dubbo-rpc-thrift/src/test/java/org/apache/dubbo/rpc/protocol/thrift)
Thrift 不支援空值,也就是說:您不能在協定中傳遞空值
最後修改日期:2023 年 2 月 22 日:合併重構網站 (#2293) (4517e8c1c9c)