proto里的message字段的编号

proto里的message不能随意更改任何现有字段的编号

proto里的message编号标识是唯一的,微服务收到的消息会按照编号匹配,编号改变会导致匹配不到值或者匹配到的值不正确,导致获取到的消息内容混乱。

//发送端服务
message ProductInfo {
    int64 id = 1;
    string name = 2;
    string url = 3;
}
//接收端服务修改后重新生成对应语言的proto文件但未修改发送端服务
message ProductInfo {
    int64 id = 1;
    string url = 2;
    string name = 3;
}
//如果是发送端的message发出的消息,接收端message的name和url的值会反过来
例如:
发送:id:1 name:apple url:test.com 
编码:8 1 18 5 apple 26 8 test.com  //根据字段类型分为T-V和T-L-V两种编码方式
收到解析:id:1 url:apple name:test.com 
本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!