A proto file is a Protocol Buffers definition file. It declares a typed message schema and can define service contracts for generated, language-specific code. Binary protobuf messages are compact and efficient to serialize, though they are not human-readable. section 4.6.2
A proto file typically specifies:
- The syntax version, such as proto3. section 4.6.2
- Language-specific generation options, including the Java package, outer class, and whether generated messages use separate files. section 4.6.2
- A protobuf package that namespaces the declared messages. section 4.6.2
- Message fields with a type, name, and unique numeric order; camel-case names are compiled into snake_case protobuf names. section 4.6.2
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;
}
The Car definition demonstrates a proto3 schema with Java generation options, an inventory namespace, and four typed fields. section 4.6.2
Generated Java code
Compiling the Car definition can produce a Java message class, builder, and serialization methods. Application code can create a Car with Car.newBuilder(), set its fields, build it, and write the encoded message to an OutputStream. section 4.6.2
Compilation can use protoc, build-tool plugins, or the Quarkus gRPC extension. For a gRPC client, the proto file supplies the service contract from which Quarkus generates stubs; the client then injects a generated stub with @GrpcClient. section 4.6.2 section 4.8.2


