6.2. Protobuf Encoding


The Infinispan Query DSL can be used remotely via the Hot Rod client. In order to do this, protocol buffers are used to adopt a common format for storing cache entries and marshalling them.

6.2.1. Storing Protobuf Encoded Entities

Protobuf requires data to be structured. This is achieved by declaring Protocol Buffer message types in .proto files
For example:

Example 6.1. .library.proto

package book_sample;  
message Book {      
      required string title = 1;
      required string description = 2;
      required int32 publicationYear = 3; // no native Date type available in Protobuf
      
      repeated Author authors = 4;
}
message Author {
    required string name = 1;
    required string surname = 2;
}

The provided example:
  1. An entity named Book is placed in a package named book_sample.
    package book_sample;  
    message Book {
    
  2. The entity declares several fields of primitive types and a repeatable field named authors.
     required string title = 1;
          required string description = 2;
          required int32 publicationYear = 3; // no native Date type available in Protobuf
          
          repeated Author authors = 4;
    }
    
  3. The Author message instances are embedded in the Book message instance.
    message Author {
        required string name = 1;
        required string surname = 2;
    }
    
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.