You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by crypto_ricklee <ri...@crypto.com> on 2020/02/27 16:42:37 UTC
How to reconnect continuous query?
Dear all,
I have a continuous query on a client node like
IgniteCache<BalancePK, Balance> cache =
ignite.getOrCreateCache(StoreHelper.getCacheName(BalanceStore.class));
ContinuousQuery<BalancePK, Balance> qry = new ContinuousQuery<>();
qry.setLocalListener(handler);
qry.setRemoteFilterFactory((Factory<CacheEntryEventFilter<BalancePK,
Balance>>) () -> event -> true);
QueryCursor<Cache.Entry<BalancePK, Balance>> cur = cache.query(qry);
It works fine, however if I restart the server node, the query seems to be
disconnected. I tried to listen to the EVT_CLIENT_NODE_RECONNECTED event and
rerun the above code segment, but it just throwing thread dump print out.
ignite.events().localListen(new IgnitePredicate<Event>() {
@Override public boolean apply(Event event) {
switch (event.type()) {
case EventType.EVT_CLIENT_NODE_DISCONNECTED:
log.info("#####Ignite Client disconnect!");
break;
case EventType.EVT_CLIENT_NODE_RECONNECTED:
log.info("#####Ignite Client reconnected!");
IgniteCache<BalancePK, Balance> cache =
ignite.getOrCreateCache(StoreHelper.getCacheName(BalanceStore.class));
ContinuousQuery<BalancePK, Balance> qry = new
ContinuousQuery<>();
qry.setLocalListener(handler);
qry.setRemoteFilterFactory((Factory<CacheEntryEventFilter<BalancePK,
Balance>>) () -> evt -> true);
QueryCursor<Cache.Entry<BalancePK, Balance>> cur =
cache.query(qry);
}
return true;
}
}, EventType.EVT_CLIENT_NODE_DISCONNECTED,
EventType.EVT_CLIENT_NODE_RECONNECTED);
Any clue?
Thanks & Regards,
Rick
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: How to reconnect continuous query?
Posted by Denis Magda <dm...@apache.org>.
Hi Rick,
What's the stack trace you see? Generally, creating/registring a new
continuous query is a proper way of reconnection handling. The issue might
be that the new query is created by a system thread that triggered your
predicate - ignite.events().localListen(new IgnitePredicate<Event>()
-
Denis
On Thu, Feb 27, 2020 at 8:42 AM crypto_ricklee <ri...@crypto.com> wrote:
> Dear all,
>
> I have a continuous query on a client node like
> IgniteCache<BalancePK, Balance> cache =
> ignite.getOrCreateCache(StoreHelper.getCacheName(BalanceStore.class));
>
> ContinuousQuery<BalancePK, Balance> qry = new ContinuousQuery<>();
>
> qry.setLocalListener(handler);
>
> qry.setRemoteFilterFactory((Factory<CacheEntryEventFilter<BalancePK,
> Balance>>) () -> event -> true);
>
> QueryCursor<Cache.Entry<BalancePK, Balance>> cur = cache.query(qry);
>
> It works fine, however if I restart the server node, the query seems to be
> disconnected. I tried to listen to the EVT_CLIENT_NODE_RECONNECTED event
> and
> rerun the above code segment, but it just throwing thread dump print out.
>
> ignite.events().localListen(new IgnitePredicate<Event>() {
> @Override public boolean apply(Event event) {
>
> switch (event.type()) {
> case EventType.EVT_CLIENT_NODE_DISCONNECTED:
> log.info("#####Ignite Client disconnect!");
> break;
> case EventType.EVT_CLIENT_NODE_RECONNECTED:
> log.info("#####Ignite Client reconnected!");
>
> IgniteCache<BalancePK, Balance> cache =
> ignite.getOrCreateCache(StoreHelper.getCacheName(BalanceStore.class));
>
> ContinuousQuery<BalancePK, Balance> qry = new
> ContinuousQuery<>();
>
> qry.setLocalListener(handler);
>
>
> qry.setRemoteFilterFactory((Factory<CacheEntryEventFilter<BalancePK,
> Balance>>) () -> evt -> true);
>
> QueryCursor<Cache.Entry<BalancePK, Balance>> cur =
> cache.query(qry);
> }
>
> return true;
> }
> }, EventType.EVT_CLIENT_NODE_DISCONNECTED,
> EventType.EVT_CLIENT_NODE_RECONNECTED);
>
>
> Any clue?
>
> Thanks & Regards,
> Rick
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>