Automatic Batching

Batch notifications to help attain high cache performance and low latency.

❗️

This is a legacy Apache Ignite documentation

The new documentation is hosted here: https://ignite.apache.org/docs/latest/

Ignite automatically groups or batches event notifications that are generated as a result of cache events occurring within the cluster.

Each activity in cache can result in an event notification being generated and sent. For systems where cache activity is high, getting notified for every event could be network intensive, possibly leading to a decreased performance of cache operations in the grid.

In Ignite, event notifications can be grouped together and sent in batches or timely intervals. Here is an example of how this can be done:

Ignite ignite = Ignition.ignite();
 
// Get an instance of named cache.
final IgniteCache<Integer, String> cache = ignite.cache("cacheName");
 
// Sample remote filter which only accepts events for keys
// that are greater than or equal to 10.
IgnitePredicate<CacheEvent> rmtLsnr = new IgnitePredicate<CacheEvent>() {
    @Override public boolean apply(CacheEvent evt) {
        System.out.println("Cache event: " + evt);
 
        int key = evt.key();
 
        return key >= 10;
    }
};
 
// Subscribe to cache events occuring on all nodes 
// that have the specified cache running. 
// Send notifications in batches of 10.
ignite.events(ignite.cluster().forCacheNodes("cacheName")).remoteListen(
		10 /*batch size*/, 0 /*time intervals*/, false, null, rmtLsnr, EVTS_CACHE);
 
// Generate cache events.
for (int i = 0; i < 20; i++)
    cache.put(i, Integer.toString(i));

X