2017-07-24 83 views
0

這是一個新手問題,感謝您的閱讀。於是,我開始的Geode服務器緩存的過程,像這樣一個複製的區域:Apache geode cachelistener未執行

gfsh>start locator --name=myLocator 

和服務器進程

start server --cache-xml-file=D:\Geode\config\cache.xml --name=myGeode --locators=localhost[10334] 

的cache.xml定義了一個叫做複製的區域myRegion

<?xml version="1.0" encoding="UTF-8"?> 
<cache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://geode.apache.org/schema/cache" 
    xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd" 
    version="1.0"> 
<cache-server/> 
<region name="myRegion" refid="REPLICATE"/> 
</cache> 

然後我使用Pivotal Native Client for .Net,在另一個進程中,我使用緩存事件偵聽器啓動客戶端緩存,如下所示:

CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(); 
Cache cache = cacheFactory.SetSubscriptionEnabled(true).Create(); 
RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY); 
IRegion<string, string> region = regionFactory.Create<string, string>("myRegion"); 
region.AttributesMutator.SetCacheListener(new MyEventHandler<string, string>()); 

的一個MyEventHandler是:

public class MyEventHandler<TKey, TVal> : ICacheListener<TKey, TVal> 
{ 
    public void AfterCreate(EntryEvent<TKey, TVal> ev) 
    { 
     Console.WriteLine("Received AfterCreate event for: {0}", ev.Key.ToString()); 
    } 
... 
} 

,然後再在第三過程中,我創建另一個緩存,這一過程把一些數據到myRegion。這是相同的設置作爲第二處理,而不監聽器:

CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(); 
Cache cache = cacheFactory.SetSubscriptionEnabled(true).Create(); 
RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY); 
IRegion<string, string> region = regionFactory.Create<string, string>("myRegion"); 
region["testKey"] = "testValue"; 

的問題是第三個進程對測試後的數據爲myRegion(我可以在服務器上看到,這樣的工作)聽者在第二過程沒有看到它。我錯過了什麼?

謝謝...

+0

Per @swapnil在設置緩存監聽器之前註冊了感興趣的東西是什麼:'region.GetSubscriptionService()。RegisterAllKeys();' – rupweb

回答