What is Protocol Buffer?
- Protocol Buffer is a technology employed in serializing the Structured Data.
- Based on Interface Description Language Methodology that describes the structure of some data and a program (here it is Protocol Buffer Compiler) that generates source code in various programming languages representing the structured data.
How to install Protocol Buffer Compiler?
- Download https://developers.google.com/protocol-buffers/docs/downloads
- Add an entry for the Path in Environment Variable Settings for Proto Buff Compiler.
- Check if ProtoBuffer is installed correctly by using the command protoc --version
Protocol Buffer Message
- Protocol Buffer Schema is described in a .proto file.
- Each Protocol Message is a logical piece of information described in Name-Value Pair.
- Single .proto file might contain multiple proto messages.
required string ram_size=1 [default="Hello World!"];
Numbers 1,2,3 are referred to as Tags. Tags are primarily used to to identify the specific field in the Binary Form.
Message Fields should be specified of one of the following
Note: Some engineers at Google have come to the conclusion that using required does more harm than good; they prefer to use only optionaland repeated. However, this view is not universal.
Geneartion of JAVA Stub from Message Schema
C:\Users\60006990>protoc --proto_path==C:\Users\60006990\Desktop --java_out=C:\U
protoc: act as the compiler
proto_path: refers to the destination
java_out: referes to the source and destination
- Copy the Generated Java File to the Package Structure
- Download the Protocol Buffer Library from http://mvnrepository.com/artifact/com.google.protobuf/protobuf-java/2.5.0