gfsh>start locator --name=myLocator
start server --cache-xml-file=D:\Geode\config\cache.xml --name=myGeode --locators=localhost[10334]
缓存。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>
然后,我使用关键的.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());
}
...
}
然后在第三个进程中,我为该进程创建另一个缓存,将一些数据放入其中
。这与没有侦听器的第二个进程的设置相同:
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";
问题是在第三个过程将测试数据放入
我的地区
(我可以在服务器上看到这一点,这样就可以工作了)第二个进程中的侦听器没有看到它。我错过了什么?
谢谢