Re: Trouble with continuous queries
Wait a sec, I have already posted an example, but for some reasons it was not send properly. Here are we go: class Program { private static IContinuousQueryHandle _continuousQuery; const string CacheName = "sample"; const string TableName = "entity"; static void Main(string[] args) { var ignite = Ignition.Start(); var cache = ignite.GetOrCreateCache(new CacheConfiguration(CacheName) { SqlSchema = "PUBLIC" }); var createTalbeSql = $"create table if not exists {TableName} (id int, field varchar, primary key (Id)) " + $"with \"key_type=int, value_type={typeof(MyEnity).FullName}\""; cache.Query(new SqlFieldsQuery(createTalbeSql)).GetAll(); ICache entityCache = ignite.GetCache($"SQL_PUBLIC_{TableName.ToUpper()}"); StartContinuousQuery(entityCache); var entity0 = new MyEnity { Id = 2, Field = "NEW" }; entityCache.Put(entity0.Id, entity0); var entity = entityCache.Get(entity0.Id); Console.WriteLine(entity); var sql = $"update {TableName} set field = 'updated' where Id = {entity.Id}"; var res = entityCache.Query(new SqlFieldsQuery(sql)).GetAll(); Console.WriteLine(res.First()[0]); sql = $"insert into {TableName} (_key, field) VALUES(7, 'new value')"; res = entityCache.Query(new SqlFieldsQuery(sql)).GetAll(); Console.WriteLine(res.First()[0]); Console.ReadLine(); _continuousQuery.Dispose(); Ignition.Stop(null, true); } public static void StartContinuousQuery(ICache cache) { var query = new ContinuousQuery(new ClrCacheSyncEventListener()); _continuousQuery = cache.QueryContinuous(query); } public class ClrCacheSyncEventListener : ICacheEntryEventListener { public void OnEvent(IEnumerable> evts) { foreach (ICacheEntryEvent cacheEntryEvent in evts) { Console.WriteLine($"Action happened {cacheEntryEvent.EventType}"); } } } public class MyEnity { public MyEnity() { } public int Id { get; set; } [QuerySqlField] public string Field { get; set; } public override string ToString() { return $"Id = {this.Id}; TextField = {this.Field};"; } } } -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Trouble with continuous queries
My next hurdle is to get a remote listener from .NET working to the cache On Thu, May 30, 2019 at 1:47 PM Mike Needham wrote: > I was able to figure this out. Was missing > the ignite.events().localListen(lsnr, EVT_CACHE_OBJECT_PUT); > > On Thu, May 30, 2019 at 12:43 PM Mike Needham wrote: > >> But does ignite fire the ignite >> event EventType.EVT_CACHE_OBJECT_PUT, EventType.EVT_CACHE_OBJECT_READ >> and EventType.EVT_CACHE_OBJECT_REMOVED >> >> On Thu, May 30, 2019 at 12:18 PM Alexandr Shapkin >> wrote: >> >>> Hi, yes, it should work that way. >>> >>> I was able to caught all events event with the raw SQL using this DBeaver >>> https://apacheignite-sql.readme.io/docs/sql-tooling >>> >>> >>> >>> >>> >>> -- >>> 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."*
Re: Trouble with continuous queries
I was able to figure this out. Was missing the ignite.events().localListen(lsnr, EVT_CACHE_OBJECT_PUT); On Thu, May 30, 2019 at 12:43 PM Mike Needham wrote: > But does ignite fire the ignite > event EventType.EVT_CACHE_OBJECT_PUT, EventType.EVT_CACHE_OBJECT_READ > and EventType.EVT_CACHE_OBJECT_REMOVED > > On Thu, May 30, 2019 at 12:18 PM Alexandr Shapkin > wrote: > >> Hi, yes, it should work that way. >> >> I was able to caught all events event with the raw SQL using this DBeaver >> https://apacheignite-sql.readme.io/docs/sql-tooling >> >> >> >> >> >> -- >> 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."*
Re: Trouble with continuous queries
But does ignite fire the ignite event EventType.EVT_CACHE_OBJECT_PUT, EventType.EVT_CACHE_OBJECT_READ and EventType.EVT_CACHE_OBJECT_REMOVED On Thu, May 30, 2019 at 12:18 PM Alexandr Shapkin wrote: > Hi, yes, it should work that way. > > I was able to caught all events event with the raw SQL using this DBeaver > https://apacheignite-sql.readme.io/docs/sql-tooling > > > > > > -- > 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."*
Re: Trouble with continuous queries
Hi, yes, it should work that way. I was able to caught all events event with the raw SQL using this DBeaver https://apacheignite-sql.readme.io/docs/sql-tooling -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Trouble with continuous queries
Do cache events fire when using SQL to update tables? My app is listening to a queue for json payloads that have the INS/UPD/DEL: for the cache entries. They are updated using SQL over the respective caches. On Wed, May 29, 2019 at 8:14 AM Mike Needham wrote: > I have tried various things, but it never fires for a change in the > cache. that is why I do not think it is set-up correctly > > > On Tue, May 28, 2019 at 9:30 AM Alexandr Shapkin > wrote: > >> Hi, >> >> You can just save an instance of continuous query somewhere and dispose it >> when required >> >> >> var listener = new SomeListener(); >> var someFilter= new >> CacheEntryEventFilter(_ignite.GetCluster().GetLocalNode(), >> Const.CacheName); >> var query = new ContinuousQuery(listener, someFilter); >> >>//save the reference in a private field >> _continuousQuery = cache.QueryContinuous(query); >> >> >> Regardless of a cache value. >> As I understand correctly you have a mixed platform solution (Java + .NET) >> This may lead to additional marshalling configuration. >> >> I will try the posted solution a bit later and reply >> >> >> >> >> -- >> 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."*
Re: Trouble with continuous queries
I have tried various things, but it never fires for a change in the cache. that is why I do not think it is set-up correctly On Tue, May 28, 2019 at 9:30 AM Alexandr Shapkin wrote: > Hi, > > You can just save an instance of continuous query somewhere and dispose it > when required > > > var listener = new SomeListener(); > var someFilter= new > CacheEntryEventFilter(_ignite.GetCluster().GetLocalNode(), > Const.CacheName); > var query = new ContinuousQuery(listener, someFilter); > >//save the reference in a private field > _continuousQuery = cache.QueryContinuous(query); > > > Regardless of a cache value. > As I understand correctly you have a mixed platform solution (Java + .NET) > This may lead to additional marshalling configuration. > > I will try the posted solution a bit later and reply > > > > > -- > 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."*
Re: Trouble with continuous queries
Hi, You can just save an instance of continuous query somewhere and dispose it when required var listener = new SomeListener(); var someFilter= new CacheEntryEventFilter(_ignite.GetCluster().GetLocalNode(), Const.CacheName); var query = new ContinuousQuery(listener, someFilter); //save the reference in a private field _continuousQuery = cache.QueryContinuous(query); Regardless of a cache value. As I understand correctly you have a mixed platform solution (Java + .NET) This may lead to additional marshalling configuration. I will try the posted solution a bit later and reply -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Trouble with continuous queries
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 exchCache = ignite.GetOrCreateCache(cacheCfg); ICollection cacheNames = ignite.GetCacheNames(); string qry = "SELECT * from EXCHANGE.EXCHANGE;"; SqlFieldsQuery qry23 = new SqlFieldsQuery(qry); var result2 = exchCache.Query(qry23).GetAll(); var qryr = new ContinuousQuery(new Listener()); 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 : ICacheEntryEventListener { public void OnEvent(IEnumerable> 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 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 : > >> Hi All, >> >> I have a cache that is running and is defined as >> IgniteCache 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 for >> cache. I have tried but it does not appear to ever be >> notified of events >> >> On Tue, May 14, 2019 at 10:55 AM Denis Mekhanikov >> 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 : >>> 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 which is a java class defining the structure. do I just set-up a ContinuousQuery On Thu, May 2, 2019 at 3:59 AM aealexsandrov 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
Re: Trouble with continuous queries
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 : > Hi All, > > I have a cache that is running and is defined as > IgniteCache 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 for > cache. I have tried but it does not appear to ever be > notified of events > > On Tue, May 14, 2019 at 10:55 AM Denis Mekhanikov > 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 : >> >>> 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 which is a >>> java class defining the structure. do I just set-up a >>> ContinuousQuery >>> >>> On Thu, May 2, 2019 at 3:59 AM aealexsandrov >>> 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."* >
Re: Trouble with continuous queries
Hi All, I have a cache that is running and is defined as IgniteCache 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 for cache. I have tried but it does not appear to ever be notified of events On Tue, May 14, 2019 at 10:55 AM Denis Mekhanikov 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 : > >> 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 which is a java >> class defining the structure. do I just set-up a ContinuousQuery> Exchange.class> >> >> On Thu, May 2, 2019 at 3:59 AM aealexsandrov >> 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."*
Re: Trouble with continuous queries
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 : > 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 which is a java > class defining the structure. do I just set-up a ContinuousQuery Exchange.class> > > On Thu, May 2, 2019 at 3:59 AM aealexsandrov > 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."* >
Re: Trouble with continuous queries
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. my example uses which is a java class defining the structure. do I just set-up a ContinuousQuery On Thu, May 2, 2019 at 3:59 AM aealexsandrov 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."*
Re: Trouble with continuous queries
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/
Trouble with continuous queries
Hi All, I have a setup that is creating a cache with two SQL tables in it. I am able to update the cache and now want to have a client use the continuous queries to be notified of any changes to the cache. the cache is using the default config and has the cache defined as IgniteCache testCache = ignite.getOrCreateCache(new CacheConfiguration<>("MAIN") .setIndexedTypes(Long.class, SecurityExchanges.class) .setIndexedTypes(Long.class, Exchange.class) .setIndexedTypes(Long.class, Department.class) .setAtomicityMode(CacheAtomicityMode.ATOMIC) .setBackups(0) ); Once the data is loaded and I update a value, how can a client listen to this to get updates? Thanks in advance -- *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."*