Hi KJQ,

A following comes to my mind:
1. Use 
IgniteEvents#remoteListen(org.apache.ignite.lang.IgniteBiPredicate<java.util.UUID,T>,
org.apache.ignite.lang.IgnitePredicate<T>, int...) with null first
predicate (locLsnr) (because notifying caller seems not needed).
2. Use IgniteCompute#broadcastAsync(org.apache.ignite.lang.IgniteCallable<R>)
in remote event handler (rmtFilter) to notify all nodes about events.

But here can be following caveats:
1. Such broadcasts can lead to poor performance, events buffering
before broadcast might help.
2. Event listeners can be also triggered for backup partitions
updates, perhaps backup notifications should be filtered to avoid
duplicate broadcasts.

Also more details about your use case can help to develop a good
solution. Currently use case is not fully clear for me.

вт, 1 окт. 2019 г. в 03:38, KJQ <k...@logicdrop.com>:
>
> I have some questions regarding Cache Listeners/Events.
>
> We have a system that used a lot of "Caffeine" based caches spread across
> multiple services (in K8S).  Basically "near-caches" (without a backing
> store).  We are now trying to fit Ignite behind those usages.
>
> *What we are trying to do is when Ignite /expires/ an entry receive the
> event on all the nodes and evict it in from Caffeine*.
>
> Are one of these approaches below correct? And/or how can I accomplish this?
> Is there a better/easier way?
>
> 1) I tried registering a CacheListener with each cache configuration but
> that seemed to only fire where the cache event was fired:
>
> config.addCacheEntryListenerConfiguration(new
> IgniteExpiredListener<>(cacheManagerProvider));
>
> 2) I am experimenting with cache events as well like this below.
>
> ig.events(
>             ig.cluster().forServers())
>             .remoteListen(
>                 new IgniteBiPredicate<UUID, CacheEvent>()
>                 {
>                     @Override
>                     public boolean apply(UUID uuid, CacheEvent evt)
>                     {
>                         log.debug("Received local event "
>                                   + evt.name()
>                                   + ", key="
>                                   + evt.key()
>                                   + ", at="
>                                   + evt.node().consistentId().toString()
>                                   + ", "
>                                   +
> evt.eventNode().consistentId().toString() );
>                         cm.getCache(evt.cacheName()).evict(evt.key());
>                         return true; // Continue listening.
>                     }
>                 },
>                 new IgnitePredicate<CacheEvent>()
>                 {
>                     @Override
>                     public boolean apply(final CacheEvent evt)
>                     {
>                         log.debug("Received remote event "
>                                   + evt.name()
>                                   + ", key="
>                                   + evt.key()
>                                   + ", at="
>                                   + evt.node().consistentId().toString()
>                                   + ", "
>                                   +
> evt.eventNode().consistentId().toString() );
>                         return true;
>                     }
>                 },
>                 EVTS_CACHE);
>
>
>
>
> -----
> KJQ
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/



-- 
Best regards,
Ivan Pavlukhin

Reply via email to