-
1. Re: Problem using continous query in infinispan 8.1
anistor Feb 2, 2016 1:15 PM (in response to udit-mishra-5113a21a)Hi,
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.
Adrian
-
2. Re: Problem using continous query in infinispan 8.1
udit-mishra-5113a21a Feb 3, 2016 12:18 AM (in response to anistor)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);
metadataCache.put("person.proto", personSchemaFile);
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;
-
3. Re: Problem using continous query in infinispan 8.1
anistor Feb 3, 2016 4:15 AM (in response to udit-mishra-5113a21a)Hi,
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.
Cheers!
-
4. Re: Problem using continous query in infinispan 8.1
udit-mishra-5113a21a Feb 4, 2016 3:09 AM (in response to anistor)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");
clearCache(remoteCache);
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())
{
System.out.println(person);
}
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..
-
5. Re: Problem using continous query in infinispan 8.1
anistor Feb 4, 2016 9:00 AM (in response to udit-mishra-5113a21a)Hi,
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
And another remote CQ sample here: https://github.com/jboss-developer/jboss-jdg-quickstarts/blob/jdg-6.6.x/remote-query/src/main/java/org/jboss/as/quickstarts/datagrid/hotrod/query/SnowForecast.java
These samples are for JDG 6.6 which is based on infinispan.
Adrian