You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by "maros.urbanec" <ma...@nokia.com> on 2019/03/26 12:59:24 UTC

Event listeners on servers only

Hi all,
  we're faced with the following requirement - when a cache entry expires
and is about to get removed from the cache, listen to the event, alter an
attribute on the entry and write it to some other cache.

It can be implemented as a client-side event listener, but that ceases to
function as soon as the client leave the topology.

/        UUID listenerId = ignite.events().remoteListen(
            (e, uuid) -> {
                System.out.println("Expired event - executed on the
client");
                return true;
            },
            e -> {
                System.out.println("Expired event - executed on one of the
servers");
                return true;
            },
            EventType.EVT_CACHE_OBJECT_EXPIRED
        );/

Calling /ignite.events(ignite.cluster().forServers()).remoteListen / instead
makes no difference as long as I can tell.

Is there any way to run an event listener on the server without a
corresponding client? Is there any way for the listener to outlive its
client?



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

RE: Event listeners on servers only

Posted by "maros.urbanec" <ma...@nokia.com>.
Thank you, both solutions verified!



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

RE: Event listeners on servers only

Posted by Stanislav Lukyanov <st...@gmail.com>.
The options I see
1. Register a local listener on each node; you can call localListen() from a broadcast() job or when the node starts. 
2. Deploy a cluster-singleton service that calls remoteListen() in its initialize().

I guess the first one will perform better.

Stan 

From: maros.urbanec
Sent: 26 марта 2019 г. 15:59
To: user@ignite.apache.org
Subject: Event listeners on servers only

Hi all,
  we're faced with the following requirement - when a cache entry expires
and is about to get removed from the cache, listen to the event, alter an
attribute on the entry and write it to some other cache.

It can be implemented as a client-side event listener, but that ceases to
function as soon as the client leave the topology.

/        UUID listenerId = ignite.events().remoteListen(
            (e, uuid) -> {
                System.out.println("Expired event - executed on the
client");
                return true;
            },
            e -> {
                System.out.println("Expired event - executed on one of the
servers");
                return true;
            },
            EventType.EVT_CACHE_OBJECT_EXPIRED
        );/

Calling /ignite.events(ignite.cluster().forServers()).remoteListen / instead
makes no difference as long as I can tell.

Is there any way to run an event listener on the server without a
corresponding client? Is there any way for the listener to outlive its
client?



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/