Source:
private void check(String node1Name, String node2Name) throws Exception { final Ignite node1 = startGrid(node1Name); final IgniteCache<Integer, MarshallerCheckingEntry> cache = node1.getOrCreateCache(CACHE_NAME); for (int i = 0; i < 10; i++) cache.put(i, new MarshallerCheckingEntry(String.valueOf(i))); final Ignite node2 = startGrid(node2Name); final ContinuousQuery<Integer, MarshallerCheckingEntry> qry = new ContinuousQuery<>(); ScanQuery<Integer, MarshallerCheckingEntry> scanQry = new ScanQuery<>(new IgniteBiPredicate<Integer, MarshallerCheckingEntry>() { @Override public boolean apply(Integer key, MarshallerCheckingEntry val) { return key % 2 == 0; } }); qry.setInitialQuery(scanQry); qry.setRemoteFilterFactory(new DummyEventFilterFactory<>()); final CountDownLatch latch = new CountDownLatch(15); qry.setLocalListener(new CacheEntryUpdatedListener<Integer, MarshallerCheckingEntry>() { @Override public void onUpdated( final Iterable<CacheEntryEvent<? extends Integer, ? extends MarshallerCheckingEntry>> evts) throws CacheEntryListenerException { System.out.println(">> Client 1 events " + evts); for (CacheEntryEvent<? extends Integer, ? extends MarshallerCheckingEntry> evt : evts) latch.countDown(); } }); final IgniteCache<Integer, MarshallerCheckingEntry> cache1 = node2.cache(CACHE_NAME); for (Cache.Entry<Integer, MarshallerCheckingEntry> entry : cache1.query(qry)) { latch.countDown(); System.out.println(">> Initial entry " + entry); } for (int i = 10; i < 20; i++) cache1.put(i, new MarshallerCheckingEntry(i)); assert latch.await(5, TimeUnit.SECONDS) : latch.getCount(); }

Target:
private void check(String node1Name, String node2Name) throws Exception { final Ignite node1 = startGrid(node1Name); final IgniteCache<Integer, MarshallerCheckingEntry> cache = node1.getOrCreateCache(CACHE_NAME); for (int i = 0; i < 10; i++) cache.put(i, new MarshallerCheckingEntry(String.valueOf(i))); final Ignite node2 = startGrid(node2Name); final ContinuousQuery<Integer, MarshallerCheckingEntry> qry = new ContinuousQuery<>(); ScanQuery<Integer, MarshallerCheckingEntry> scanQry = new ScanQuery<>(new IgniteBiPredicate<Integer, MarshallerCheckingEntry>() { @Override public boolean apply(Integer key, MarshallerCheckingEntry val) { return key % 2 == 0; } }); qry.setInitialQuery(scanQry); qry.setRemoteFilterFactory(new DummyEventFilterFactory<>()); final CountDownLatch latch = new CountDownLatch(15); qry.setLocalListener(new CacheEntryUpdatedListener<Integer, MarshallerCheckingEntry>() { @Override public void onUpdated( final Iterable<CacheEntryEvent<? extends Integer, ? extends MarshallerCheckingEntry>> evts) throws CacheEntryListenerException { System.out.println(">> Client 1 events " + evts); for (CacheEntryEvent<? extends Integer, ? extends MarshallerCheckingEntry> evt : evts) latch.countDown(); } }); final IgniteCache<Integer, MarshallerCheckingEntry> cache1 = node2.cache(CACHE_NAME); for (Cache.Entry<Integer, MarshallerCheckingEntry> entry : cache1.query(qry)) { latch.countDown(); System.out.println(">> Initial entry " + entry); } for (int i = 10; i < 20; i++) cache1.put(i, new MarshallerCheckingEntry(i)); assertTrue(Long.toString(latch.getCount()), latch.await(5, TimeUnit.SECONDS)); }