private const string CacheName = "EXCHANGE";

        static void Main(string[] args)
        {

            using (var ignite =
Ignition.Start("E:\\ignite\\apache-ignite-2.7.0-src\\examples\\config\\example-igniteClient.xml"))
            {
                {
                    var cacheCfg = new CacheConfiguration
                    {
                        Name = CacheName, //"port2",
                        SqlSchema = "EXCHANGE"
                    };
                    ICache<long, object> exchCache =
ignite.GetOrCreateCache<long, object>(cacheCfg);
                    ICollection<string> cacheNames = ignite.GetCacheNames();

                    string qry = "SELECT * from EXCHANGE.EXCHANGE;";
                    SqlFieldsQuery qry23 = new SqlFieldsQuery(qry);
                    var result2 = exchCache.Query(qry23).GetAll();

                    var qryr = new ContinuousQuery<long, object>(new
Listener<object>());
                    using (exchCache.QueryContinuous(qryr))
                    {
                        while (true)
                        {
                            Thread.Sleep(2000);
                        }
                    }

                    Console.WriteLine();
                    Console.WriteLine(">>> Example finished, press any key
to exit ...");
                    Console.ReadKey();

                }
            }
        }

        private class Listener<T> : ICacheEntryEventListener<long, T>
        {
            public void OnEvent(IEnumerable<ICacheEntryEvent<long, T>>
events)
            {
                foreach (var e in events)
                    Console.WriteLine("Queried entry [key=" + e.Key + ",
val=" + e.Value + ']');
            }
        }


On Wed, May 22, 2019 at 3:29 AM Denis Mekhanikov <[email protected]>
wrote:

> Mike,
>
> Could you show the code, that you use to register the continuous query?
> Maybe there is some misconfiguration?
>
> Denis
>
> пн, 20 мая 2019 г. в 17:47, Mike Needham <[email protected]>:
>
>> Hi All,
>>
>> I have a cache that is running and is defined as
>>             IgniteCache<Object, Object> exchCache =
>> ignite.getOrCreateCache(new CacheConfiguration<>("EXCHANGE")
>>             .setIndexedTypes(Long.class, Exchange.class)
>>             .setAtomicityMode(CacheAtomicityMode.ATOMIC)
>>             .setBackups(0)
>>             );
>>
>> from a dotnet client how can I get a continuous query so that I am
>> notified of the changes to the cache?  I can access the cache VIA DBeaver
>> and other sql tools.
>>
>> the documentation does not make it clear how to set this up.  I want ALL
>> changes to the cache to be sent to the client.  The DOTNET example does not
>> appear to work for this scenario.  It is using a simple <int,string> for
>> cache.  I have tried <object,object> but it does not appear to ever be
>> notified of events
>>
>> On Tue, May 14, 2019 at 10:55 AM Denis Mekhanikov <[email protected]>
>> wrote:
>>
>>> Mike,
>>>
>>> First of all, it's recommended to have a separate cache per table to
>>> avoid storing of objects of different types in the same cache.
>>>
>>> Continuous query receives all updates on the cache regardless of their
>>> type. Local listener is invoked when new events happen. Existing records
>>> can be processed using initial query.
>>>
>>> Refer to the following documentation page for more information:
>>> https://apacheignite.readme.io/docs/continuous-queries
>>>
>>> Denis
>>>
>>> чт, 2 мая 2019 г. в 14:14, Mike Needham <[email protected]>:
>>>
>>>> I have seen that example, what I do not understand is I have two SQL
>>>> tables in a cache that has n number of nodes.  it is loaded ahead of time
>>>> and a client wants to be notified when the contents of the cache are
>>>> changed.  Do you have to have the continuous query in a never ending loop
>>>> to not have it end?  All the examples are simply using ContinuousQuery<
>>>> Integer, String>. my example uses <Long, Exchange.class> which is a
>>>> java class defining the structure.  do I just set-up a
>>>> ContinuousQuery<Long, Exchange.class>
>>>>
>>>> On Thu, May 2, 2019 at 3:59 AM aealexsandrov <[email protected]>
>>>> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> The good example of how it can be done you can see here:
>>>>>
>>>>>
>>>>> https://github.com/gridgain/gridgain-advanced-examples/blob/master/src/main/java/org/gridgain/examples/datagrid/query/ContinuousQueryExample.java
>>>>>
>>>>> You can set remote listener to handle changes on remote nodes and local
>>>>> listers for current.
>>>>>
>>>>> Note that you will get the updates only until ContinuousQuery will not
>>>>> be
>>>>> closed or until the node that starts it will not left the cluster.
>>>>>
>>>>> Also, you can try to use CacheEvents like in example here:
>>>>>
>>>>> https://apacheignite.readme.io/docs/events#section-remote-events
>>>>>
>>>>> Note that events can affect your performance.
>>>>>
>>>>> BR,
>>>>> Andrei
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>>>>
>>>>
>>>>
>>>> --
>>>> *Don't be afraid to be wrong. Don't be afraid to admit you don't have
>>>> all the answers. Don't be afraid to say "I think" instead of "I know."*
>>>>
>>>
>>
>> --
>> *Don't be afraid to be wrong. Don't be afraid to admit you don't have all
>> the answers. Don't be afraid to say "I think" instead of "I know."*
>>
>

-- 
*Don't be afraid to be wrong. Don't be afraid to admit you don't have all
the answers. Don't be afraid to say "I think" instead of "I know."*

Reply via email to