Protocol Buffers

Aksshar Ramesh
3 min readJan 31, 2021

In this section, we are going to discuss what protocol buffers are.

Json has become the standard way for inter services communication, even though they were not really designed for this. We often think that design is good because it’s language and platform neutral. So what if we design our application with something which is also platform neutral language neutral, optimized for inter services communication, and can also provide all the client libraries automatically?

That is what the protocol or protobuf in short is.

So protocol buffer is nothing but an interface Description Language IDs for your API. So it’s something like the wisdom for your web services using XML soap. So it’s platform neutral language neutral, and it’s a mechanism for serializing and deserializing structured data very fast and optimized for interesting business communication. Let’s consider I have a platform class like this with the platDesc and platNumber fields.

If this is your data transfer object? Then protobuf ask us to create a type like this. Note here, we use the message keywords for the title for our class. Here we have two fields for platDesc and platNumber. You might wonder why the string isn’t small? What is this int32?

So this is the Java type and the proto corresponding the proto type you have to use, these are the primitive types of protocol buffers, basic building blocks using which you build other complex types in production. There is no characters single byte character, so we have at least three in bytes.

Proto Types

protobuf supports collection, map as well. So, we have to use a repeater for collection.

Default Values

It assumes there is no null input. Proto have some default values.

There are some rules when managing proto files when working with micro services.

You can learn more about protocol buffers from here.

https://developers.google.com/protocol-buffers/docs/overview

--

--

Aksshar Ramesh

AI Security Research fellow at Centre for Sustainable Cyber Security, University of Greenwich