I would advise against using the initial query for building a consistent view 
because of the way the feature is currently implemented in Ignite. The current 
API makes it impossible to establish the ordering relationship between the 
events delivered via the CQ listener and the data items returned by the initial 
query. The reason is that the CQ events and the initial results are delivered 
by different threads.


Imagine the following sequence of events in the system:


1) the initial query thread reads the current value of the key K1 => V1 and 
then it gets preempted

2) in the meantime, concurrent transaction updates K1 to V2 and the CQ listener 
gets dispatched with V2

3) the query thread resumes and the V1 value is returned from the query 
iterator.


In this example, the code that is using the data coming from the initial query 
and the CQ listener ends up processing events out of order.


The correct implementation of this feature would deliver all data to the same 
listener instance: first send the initial snapshot, followed by the special 
"end of snapshot" marked, followed by the CQ events.

Regards
Andrey

________________________________
From: vkulichenko <[email protected]>
Sent: Friday, September 23, 2016 3:03 PM
To: [email protected]
Subject: Re: How to avoid the event lost in the continuous query

Hi,

You can use ContinuousQuery.setInitialQuery to get the state of the cache at
the moment of query execution. The results for this query will be returned
in the cursor returned from the query() method. Note that in this case
listener is actually registered before the initial query execution, so there
will be no lost events, but duplicates are possible.

-Val



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/How-to-avoid-the-event-lost-in-the-continuous-query-tp7904p7922.html
Apache Ignite Users - How to avoid the event lost in the continuous 
query<http://apache-ignite-users.70518.x6.nabble.com/How-to-avoid-the-event-lost-in-the-continuous-query-tp7904p7922.html>
apache-ignite-users.70518.x6.nabble.com
How to avoid the event lost in the continuous query. Following is my test steps 
about continuous query. step 1: Start an Ignite Server by command "sh 
ignite.sh". step 2: Start an Ignite Client, it...



Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to