You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2018/11/21 07:47:02 UTC

[incubator-dubbo-website] branch asf-site updated: add RPC protocol description

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

liujun pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new e3f8127  add RPC protocol description
e3f8127 is described below

commit e3f812727a5d58ad9f3921647349afcdedb855a6
Author: ken.lj <ke...@gmail.com>
AuthorDate: Wed Nov 21 15:46:58 2018 +0800

    add RPC protocol description
---
 docs/zh-cn/dev/implementation.md | 71 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/docs/zh-cn/dev/implementation.md b/docs/zh-cn/dev/implementation.md
index c1f664b..7225052 100644
--- a/docs/zh-cn/dev/implementation.md
+++ b/docs/zh-cn/dev/implementation.md
@@ -136,6 +136,77 @@ public class DemoServiceImpl implements DemoService {
 
 ![/dev-guide/images/dubbo_protocol_header.jpg](sources/images/dubbo_protocol_header.png)
 
+
+- Magic - Magic High & Magic Low (16 bits)
+  
+  Identifies dubbo protocol with value: 0xdabb
+  
+- Req/Res (1 bit)
+  
+  Identifies this is a request or response. Request - 1; Response - 0.
+  
+- 2 Way (1 bit)
+  
+  Only useful when Req/Res is 1 (Request), expect for a return value from server or not. Set to 1 if need a return value from server.
+  
+- Event (1 bit)
+  
+  Identifies an event message or not, for example, heartbeat event. Set to 1 if this is an event.
+  
+- Serialization ID (5 bit)
+  
+  Identifies serialization type: the value for fastjson is 6.
+  
+- Status (8 bits)
+  
+  Only useful when  Req/Res is 0 (Response), identifies the status of response
+  
+  - 20 - OK
+  - 30 - CLIENT_TIMEOUT
+  - 31 - SERVER_TIMEOUT
+  - 40 - BAD_REQUEST
+  - 50 - BAD_RESPONSE
+  - 60 - SERVICE_NOT_FOUND
+  - 70 - SERVICE_ERROR
+  - 80 - SERVER_ERROR
+  - 90 - CLIENT_ERROR
+  - 100 - SERVER_THREADPOOL_EXHAUSTED_ERROR
+    
+- Request ID (64 bits)
+  
+  Identifies an unique request. Numeric (long).
+  
+- Data Length (32)
+  
+  Length of the content (the variable part) after serialization, counted by bytes. Numeric (integer).
+  
+- Variable Part
+  
+  Each part is a byte[] after serialization with specific serialization type, identifies by Serialization ID.
+  
+Every part is a byte[] after serialization with specific serialization type, identifies by Serialization ID
+
+1. If the content is a Request (Req/Res = 1), each part consists of the content, in turn is:
+   - Dubbo version
+   - Service name
+   - Service version
+   - Method name
+   - Method parameter types
+   - Method arguments
+   - Attachments 
+
+1. If the content is a Response (Req/Res = 0), each part consists of the content, in turn is:
+   - Return value type, identifies what kind of value returns from server side: RESPONSE_NULL_VALUE - 2, RESPONSE_VALUE - 1, RESPONSE_WITH_EXCEPTION - 0.
+   -  Return value, the real value returns from server.
+
+
+**注意:**对于(Variable Part)变长部分,当前版本的dubbo框架使用json序列化时,在每部分内容间额外增加了换行符作为分隔,请选手在Variable Part的每个part后额外增加换行符, 如:
+```
+Dubbo version bytes (换行符)
+Service name bytes  (换行符)
+...
+```
+
 ### 线程派发模型
 
 ![/dev-guide/images/dubbo-protocol.jpg](sources/images/dubbo-protocol.jpg)