我在尝试访问/加入外部一致性群集时遇到问题 . 在我当前的项目中,我有一个服务器(不是localhost)运行一致性集群,我需要加入该集群以从该缓存中获取数据 .
我正在尝试这个简单的代码,但它一直在我自己的机器上创建一致性(localhost)
public static void main(String[] args){
XmlElement opConfig = XmlHelper.loadFileOrResource("C:\\Users\\916001\\Documents\\NetBeansProjects\\testAppProject\\src\\main\\resources\\tangosol-coherence-override.xml", "ACCESS_EXTERNAL_SERVER");
NamedCache coherenceCache = CacheFactory.getCache("osbhmlmensage");
System.out.println(CacheFactory.getCluster());
}
我期待的是加载“opConfig”,然后使用“CacheFactory.getCache”访问集群
在tangosol-coherence-override我把这个:
<unicast-listener>
<socket-provider system-property="tangosol.coherence.socketprovider"/>
<reliable-transport system-property="tangosol.coherence.transport.reliable"/>
<well-known-addresses>
<socket-address id="1">
<address system-property="tangosol.coherence.wka">xxx.xxx.xxx.xxx</address>
<port system-property="tangosol.coherence.wka.port">yyyy</port>
</socket-address>
</well-known-addresses>
</unicast-listener>
在地址中我把服务器的IP和端口放在集群的端口上
我是oracle coherence缓存的新手,我目前正在使用Coherence 3.7 .
谢谢!
1 回答
您使用
XmlHelper.loadFileOrResource
读取配置,但不在任何地方使用它 . 在创建命名高速缓存之前,应将此配置作为参数调用CacheFactory.setCacheFactoryBuilderConfig
: