the code looks ok but there's a small detail missing. Besides registering the proto file with the client's ProtoStreamMarshaller you also need to register the proto file with the server. The registration mechanism is very simple. It is just a cache in which you need to put the file as in the example below:
RemoteCache<String, String> metadataCache = remoteCacheManager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
metadataCache.put("person.proto", ...read that CP resource into a String somehow...);
This cache is persistent and replicated, so registration with the server needs to be done only once. The registration on the client side however will be needed every time you instantiate the RemoteCacheManager.
Hello anistor, thanks for your reply. I could solve the problem by writing this -
ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder();
String personSchemaFile = protoSchemaBuilder.fileName("person.proto").packageName("marshaller").addClass(Person.class).build(serCtx);
RemoteCache metadataCache = rmc.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
Additionally I had to annotate the fields of Person class like this -
@ProtoField(number = 1)
public String name;
@ProtoField(number = 2, required = true)
public int age = 20;
metadataCache.put("person.proto", personSchemaFile) did the trick.
Switching to @Proto* annotations and generating the proto file with ProtoSchemaBuilder instead of writing the schema manually is an alternative but the initial approach should have worked too.
Sorry to bother you mate, I could this using simple Queries. I am giving the snippet, how we used it
RemoteCache<Object, Object> remoteCache = rmc.getCache("CollaborateDistributedCache1");
remoteCache.put(1, new Person("Udit Mishra", 23));
remoteCache.put(2, new Person("Amit Jha", 32));
remoteCache.put(3, new Person("Sumit Sagar", 28));
QueryFactory<Query> qf = Search.getQueryFactory(remoteCache);
Query query = qf.from(Person.class).having("name").eq("Udit Mishra").or().having("age").gt(30).toBuilder().build();
for (Person person : query.list())
and Its working excellently, now I want to use Continuous queries, I have searched a lot, but couldn't find satisfactory example. I have seen the listener, but could you please tell me how to instantiate the Continous query and listing the results. A basic example snippet would be very helpful for me..
A small CQ sample can be found in this blog post: http://blog.thomasqvarnstrom.com/2016/01/new-release-of-jboss-data-grid-66.html
You can also find other remote query samples here: https://github.com/jboss-developer/jboss-jdg-quickstarts/tree/jdg-6.6.x/remote-query
These samples are for JDG 6.6 which is based on infinispan.