When I try ContinuousQuery I am getting events for the records I am not
subscribed to.
Entity Class
public class Profile implements Serializable{
@QuerySqlField(index = true)
private String number;
@QuerySqlField(index = true)
private Double dataUsage;
}
Update Profile Method
void updateAnyProfile(Double newDataUsage){
SqlQuery qry = new SqlQuery(Profile.class,"select * from Profile where
dataUsage < 30");
List<CacheEntryImpl<String, Profile>> res =
profileCache.query(qry).getAll();
Profile profile = res.iterator().next().getValue();
profile.setDataUsage(newDataUsage);
veonProfileCache.put(profile.getNumber(), profile);
}
Query method
QueryCursor<Entry<String,BinaryObject>>
detectChangesNoRemoteFilter(double start, double end) throws Exception{
ContinuousQuery<String, BinaryObject> qry = new
ContinuousQuery<>();
SqlQuery sqlQry = new SqlQuery(Profile.class,"dataUsage > ? and
dataUsage
< ? ");
sqlQry.setArgs(start,end);
qry.setInitialQuery(sqlQry);
qry.setLocalListener((evts) ->
evts.forEach(e -> {
System.out.println("Inserting/Updating profiles
with more than
%"+start+" key=" + e.getKey() + ", dataUsage=" +
e.getValue().field("dataUsage"));
}));
qry.setRemoteFilterFactory(new
Factory<CacheEntryEventFilter<String,BinaryObject>>() {
public CacheEntryEventFilter<String, BinaryObject>
create() {
return new CacheEntryEventFilter<String,
BinaryObject>() {
public boolean
evaluate(CacheEntryEvent<? extends String, ? extends
BinaryObject> e)
throws
CacheEntryListenerException {
return true;
}
};
}
});
IgniteCache<BinaryObject, BinaryObject> cache =
Ignition.ignite().cache("profileCache").withKeepBinary();
QueryCursor<Entry<String, BinaryObject>> cursor =
cache.query(qry);
return cursor;
}
And registering the ContinuousQuery as below
QueryCursor<Entry<String, BinaryObject>> cursor30 =
profileService.detectChangesNoRemoteFilter(30,33);
Updating a profile with dataUSage is less than 30 to 51 and still getting
notifications which i should not since the data change is irrelevant to my
initial query. If that is the case then ContinuousQueries are not working as
mentioned in the document
profileService.updateAnyProfile(51D);
>From https://apacheignite.readme.io/docs/continuous-queries
Continuous queries enable you to listen to data modifications occurring on
Ignite caches. Once a continuous query is started, you will get notified of
all the data changes that fall into your query filter if any.
--
View this message in context:
http://apache-ignite-developers.2346864.n4.nabble.com/ContiniousQuery-giving-notification-for-different-dataset-tp17538.html
Sent from the Apache Ignite Developers mailing list archive at Nabble.com.