Protocol Buffers, or protobuf, is a compact, efficient, language-independent serialization format for typed structured data. A proto schema describes the messages, while tooling generates language-specific classes that serialize and deserialize them. Binary messages are smaller and faster than JSON, but they are not human-readable. section 4.6.2
A proto file declares proto3 syntax, namespaces, language-specific options, and message fields. Each field has a type, name, and numeric order; generated code follows protobuf naming conventions, such as converting licensePlateNumber to license_plate_number. section 4.6.2
A protobuf workflow typically proceeds as follows:
- Define messages and, when needed, remote methods in a .proto file. section 4.7
- Compile the file with protoc, a build-tool plugin, or Quarkus's quarkus-grpc extension. section 4.6.2 section 4.7
- Use generated message builders for application data and generated client or server stubs for gRPC calls. section 4.6.2 section 4.7
Car message and generated builder
A Car message can contain license_plate_number, manufacturer, model, and id fields. Generated Java code then supports Car.newBuilder(), field setters, build(), and writeTo(outputStream) for constructing and serializing an instance.
Listing 4.31 Describing the Car model using Protocol Buffers
syntax = "proto3";
option java_multiple_files = true;
option java_package = "org.acme.inventory.model";
option java_outer_classname = "InventoryProtos";
package inventory;
message Car {
string license_plate_number = 1;
string manufacturer = 2;
string model = 3;
int64 id = 4;
}
Inspect the complete proto3 Car schema, including Java generation options, the inventory namespace, field types, and field numbers. section 4.6.2
With Quarkus gRPC, placing inventory.proto under src/main/proto and running ./mvnw clean package generates Java message classes, service bases, and client stubs. This supports compact service communication while leaving business implementations in application code. section 4.7









