You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by jcalahor <jc...@yahoo.com> on 2018/10/23 20:18:44 UTC
remote filter for ContinuousQuery on C#
hi,
how i can subscribe to just 1 object? The documentation is not clear about
how to create Remote Filters/Scan Filters. Below is is my code. i just need
to be notified to 1 particular object(id = 1), not all.
using Apache.Ignite.Core;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache.Event;
using Apache.Ignite.Core.Cache.Query;
using Apache.Ignite.Core.Cache.Query.Continuous;
using Apache.Ignite.Core.Client;
using Apache.Ignite.Core.Client.Cache;
using Apache.Ignite.Core.Discovery.Tcp;
using Apache.Ignite.Core.Discovery.Tcp.Static;
using Apache.Ignite.Core.Events;
using System;
using System.Collections.Generic;
using System.Linq;
namespace test_console
{
class Program
{
private class Listener<T> : ICacheEntryEventListener<int, T>
{
public void OnEvent(IEnumerable<ICacheEntryEvent<int, T>>
events)
{
foreach (var e in events)
Console.WriteLine("Queried entry [key=" + e.Key + ",
val=" + e.Value + ']');
}
}
static void Main(string[] args)
{
Ignition.ClientMode = true;
using (var ignite =
Ignition.Start(@"C:\apache_ignite\examples\config\example-ignite.xml"))
{
var persons = ignite.GetCache<int,
IBinaryObject>("City").WithKeepBinary<int, IBinaryObject>();
var localListener = new Listener<IBinaryObject>();
var qry = new ContinuousQuery<int,
IBinaryObject>(localListener);
var query = new SqlQuery("City", "select * from City where
id = 1");
var queryHandle = persons.QueryContinuous(qry, query);
foreach (var entry in queryHandle.GetInitialQueryCursor())
Console.WriteLine("key={0}, val={1}", entry.Key,
entry.Value);
Console.ReadLine();
}
}
}
}
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: remote filter for ContinuousQuery on C#
Posted by jcalahor <jc...@yahoo.com>.
that helped, thx!
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: remote filter for ContinuousQuery on C#
Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!
Yes, you should be able to do that. Just specify a ICacheEntryEventFilter
implementation that will check that Key == 1 in Evaluate() as a second
constructor parameter.
Note that you have to run .Net Apache Ignite on all nodes in order C#
remote filters to work.
Regards,
--
Ilya Kasnacheev
вт, 23 окт. 2018 г. в 23:18, jcalahor <jc...@yahoo.com>:
> hi,
>
>
> how i can subscribe to just 1 object? The documentation is not clear about
> how to create Remote Filters/Scan Filters. Below is is my code. i just need
> to be notified to 1 particular object(id = 1), not all.
>
>
>
> using Apache.Ignite.Core;
> using Apache.Ignite.Core.Binary;
> using Apache.Ignite.Core.Cache.Event;
> using Apache.Ignite.Core.Cache.Query;
> using Apache.Ignite.Core.Cache.Query.Continuous;
> using Apache.Ignite.Core.Client;
> using Apache.Ignite.Core.Client.Cache;
> using Apache.Ignite.Core.Discovery.Tcp;
> using Apache.Ignite.Core.Discovery.Tcp.Static;
> using Apache.Ignite.Core.Events;
> using System;
> using System.Collections.Generic;
> using System.Linq;
>
> namespace test_console
> {
>
> class Program
> {
> private class Listener<T> : ICacheEntryEventListener<int, T>
> {
> public void OnEvent(IEnumerable<ICacheEntryEvent<int, T>>
> events)
> {
> foreach (var e in events)
> Console.WriteLine("Queried entry [key=" + e.Key + ",
> val=" + e.Value + ']');
> }
> }
>
> static void Main(string[] args)
> {
> Ignition.ClientMode = true;
> using (var ignite =
> Ignition.Start(@"C:\apache_ignite\examples\config\example-ignite.xml"))
> {
> var persons = ignite.GetCache<int,
> IBinaryObject>("City").WithKeepBinary<int, IBinaryObject>();
> var localListener = new Listener<IBinaryObject>();
> var qry = new ContinuousQuery<int,
> IBinaryObject>(localListener);
>
> var query = new SqlQuery("City", "select * from City where
> id = 1");
>
>
> var queryHandle = persons.QueryContinuous(qry, query);
> foreach (var entry in queryHandle.GetInitialQueryCursor())
> Console.WriteLine("key={0}, val={1}", entry.Key,
> entry.Value);
> Console.ReadLine();
> }
>
>
> }
> }
> }
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>