ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alper Tekinalp <al...@evam.com>
Subject Re: ContiniousQuery giving notification for different dataset
Date Mon, 08 May 2017 08:53:27 GMT
Hi Fatih.

Documentation for initial query says: "an initial query that will be
executed before the continuous query gets registered in the cluster and
before you start to receive the updates". So it will only be executed once.
To further filter events you must implement it on filter logic. Your filter
implementation always returns true.

On Mon, May 8, 2017 at 12:01 AM, fatih <fatih.tekin85@gmail.com> wrote:

> 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&lt;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&lt;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&lt;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&lt;String, BinaryObject>> cursor =
> cache.query(qry);
>                 return cursor;
>         }
>
> And registering the ContinuousQuery as below
>                         QueryCursor<Entry&lt;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.
>



-- 
Alper Tekinalp

Software Developer
Evam Streaming Analytics

Atatürk Mah. Turgut Özal Bulv.
Gardenya 5 Plaza K:6 Ataşehir
34758 İSTANBUL

Tel:  +90 216 455 01 53 Fax: +90 216 455 01 54
www.evam.com.tr
<http://www.evam.com>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message