Details
-
Enhancement
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
-
Undefined
Description
Register the schema can be done by
- grab the generated schema from @AutoProtoSchemaBuilder -> target/classes/<package>/*.proto
- register any *proto for the server by using CLI/CR (OCP) or other interface
But often the client code is used to register it from the SchemaBuilder or other ways.
The needed code is not intuitive and contains a lot of (unnecessary) implementation knowledge like followed
~~~
private void registerSchemas(SerializationContextInitializer initializer) {
final RemoteCache<String, String> protoMetadataCache = remoteCacheManager.getCache("___protobuf_metadata"); // ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME is only available if query dependency is set
// add the schema to the server side
protoMetadataCache.put(initializer.getProtoFileName(), initializer.getProtoFile());
// check for definition error for the registered protobuf schemas
String errors = protoMetadataCache.get(".errors"); // ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX is only available if query dependency is set
if (errors != null)
}
~~~
As seen the correct cache name for the protobuf metadata, the RCM must be used and the errors must be checked.
It would be smart if this is hidden inside of the RemoteBuilder or CacheManager by simple invocation of a method which need the file to load from the classpath or name+content.
In that case the internal use of the cache is hidden and the Method should fail with an Exception if the file can't be registered.