【发布时间】:2020-06-26 09:18:41
【问题描述】:
我玩过 Ignite 微服务示例 https://github.com/dmagda/MicroServicesExample。我添加了一个事件监听器,并明确订阅了特定的缓存
数据节点配置.xml:
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="includeEventTypes">
<util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
</property>
DataNodeStartup.java:
ignite.events(ignite.cluster().forCacheNodes("vehicles")).remoteListen(locLsnr, rmtLsnr,
EVT_CACHE_OBJECT_PUT, EVT_CACHE_OBJECT_READ, EVT_CACHE_OBJECT_REMOVED);
但我总是捕捉到另一个缓存“维护”的意外事件。
forCacheNodes("vehicles") 不起作用还是我的配置错误?
更新:
我正在听这样的事件
IgnitePredicate<CacheEvent> rmtLsnr = new IgnitePredicate<CacheEvent>() {
@Override
public boolean apply(CacheEvent evt) {
System.out.println("Cache event [name=" + evt.name() + ", newValue : " + evt.newValue() + "]");
return true;
}
};
【问题讨论】: