Author: Editorial Team
-
Protocol Buffers and Uniqueness in Collections
When developers start using repeated fields in Protocol Buffers, a very natural and frequently asked question appears sooner or later: “If repeated behaves like a list, what should I do when I want only unique items like a Set?” This question is completely valid, but it reveals a deeper conceptual confusion about what Protocol Buffers…
-
Protocol Buffers Collections
So far, we have modeled single objects in Protocol Buffers, such as a Person, Address, or Student. However, real-world systems often need to handle collections of items, such as a list of books in a library, a list of orders in an e-commerce system, or a list of messages in a chat application. In this…
-
Protocol Buffers Composition
1. Introduction In this tutorial, we move to the next important concept in Protocol Buffers: composition, where one message type contains another message type as a field. This is very similar to object composition in Java, where one class holds a reference to another class. 2. What is Composition in Protobuf? Composition in Protobuf means:…
-
Protobuf Serialization and Deserialization in Java
1. Introduction When we use Protocol Buffers in real applications, defining messages is only the first step, because the true power of Protobuf appears when we serialize those messages into a compact binary form for transmission or storage, and later deserialize them back into objects. In this tutorial, we will focus on the essential ideas…
-
Understanding Scalar Types in Protocol Buffers
1. Introduction In Java, we begin learning data modeling with primitive data types such as int, long, float, double, char, and boolean, and these primitives act as the fundamental building blocks from which we construct classes, and then through composition of classes we gradually build richer abstractions that model real-world problems. Protocol Buffers follows a…
-
Equals and clear method with a Protobuf object
In this tutorial, we will explore how a Protocol Buffers (Protobuf) generated Person object behaves in Java, especially in terms of: 1. Reusing the Existing Person Class Assume you already generated a Person class from a .proto file and created a helper method to build a person object. For example: Moving creation logic into a…
-
Generating Separate Java Classes from Protobuf Messages with java_multiple_files
1. Introduction When working with Protobuf in Java projects, one common surprise is the “outer class” that Protobuf generates around your messages. Many developers expect to access their message types directly, but instead they find themselves navigating through a wrapper class. This tutorial explains: We will build a clear mental model so you understand what…
-
Organizing Protobuf Files with package
1. Introduction When your project grows and you start adding multiple .proto files, especially copies or variations of similar messages, simple folder organization is not enough. Protobuf (protoc) does not treat directories the same way Java developers do. Instead, it relies on explicit package definitions and Java generation options to avoid naming conflicts. 2. The…
-
Setting Up the Protobuf Playground Project
1. Creating the Maven Project You can use any IDE you like, but in this tutorial we will assume IntelliJ IDEA. Create a new Maven project with the name: gRPC-playground The word playground is intentional. It reminds us that: Use: Once the project is created, let Maven finish importing and indexing. 2. Installing the Protobuf…
-
Protocol Buffers: Why They Exist and What Problem They Solve
1. Communication in a Microservices World In a modern microservices architecture, we almost never deal with a single standalone application. Instead, the system is composed of many small services, each responsible for a specific piece of functionality, and these services continuously talk to each other in order to handle a single user request. One service…
