6.2.3. Using Protobuf with Hot Rod
Protobuf can be used with JBoss Data Grid's Hot Rod using the following two steps:
- Configure the client to use a dedicated marshaller, in this case, the
ProtoStreamMarshaller. This marshaller uses theProtoStreamlibrary to assist in encoding objects.Important
In order to use theProtoStreamMarshaller, the infinispan-remote-query-client Maven dependency must be added. - Instruct
ProtoStreamlibrary on how to marshall message types by registering per entity marshallers.
The following example describes how to use the
ProtoStreamMarshaller to encode and marshall messages.
In the provided example,
- The
SerializationContextis provided by theProtoStreamlibrary. - The
SerializationContext.registerProtofilemethod receives the name of a classpath resource that is a serialized protobuf binary descriptor containing the type declarations. The binary descriptor,.protobin, is compiled with Protobuf's protoc generator tool using thecommand line option for the--descriptor_set_out
--descriptor_set_outCopy to Clipboard Copied! Toggle word wrap Toggle overflow library.protofile. - The
SerializationContextassociated with theRemoteCacheManageris obtained, thenProtoStreamis instructed to marshall the protobuf types.
Note
A
RemoteCacheManager has no SerializationContext associated with it unless it was configured to use ProtoStreamMarshaller.