Reputation: 59
I am looking for a way to register single cache's cache event with ignite.
It is possible to register all put events of ignite envoriment with this code;
IgniteBiPredicate<UUID, CacheEvent> lsnr = new IgniteBiPredicate<UUID, CacheEvent>() {
@Override public boolean apply(UUID uuid, CacheEvent evt) {
System.out.println("Received event [evt=" + evt.name() + ", key=" + evt.key() +
", oldVal=" + evt.oldValue() + ", newVal=" + evt.newValue());
return true; // Continue listening.
}
};
ignite.events().localListen(lsnr, EventType.EVT_CACHE_OBJECT_PUT);
But i would like to register only cache event for specific map(cache) because of performance reasons. Otherwise, i will have to check cache name for each event, which could cause huge load on system with a high number of transactions.
Thanks for any help and guidance.
Upvotes: 1
Views: 636
Reputation: 8390
If you want to listen to data updates, continuous queries are better option: https://apacheignite.readme.io/docs/continuous-queries
This feature works on per-cache level, supports proper event ordering and guarantees delivery in case of topology changes.
Upvotes: 1