如何使用 ClientCache 在所有集群/实例上的 GemFire 中发布

How to publish in GemFire on all clusters / instances using ClientCache

我们有 3 个集群(美国、欧盟、亚太地区),每个集群有 2 个主机(一个主要的,另一个次要的)

如果有更新,每个集群的主主机都会更新同一个集群中的从主机。但是集群之间不相互交谈。

我们有一个进程需要更新每个集群的主要主机上的所有 3 个 GemFire 缓存 运行(最终将更新辅助主机 GemFire)

cache-cluster-1.xml 
   <client-cache>
     <pool name="clientCachePool" read-timeout="90000" >
        <server host="pri1-hostname" port="1111"  />
        <server host="sec1-hostname" port="1111"  />
     </pool>
     <region>...</region>
   <client-cache>

cache-cluster-2.xml 
   <client-cache>
     <pool name="clientCachePool" read-timeout="90000" >
        <server host="pri2-hostname" port="1111"  />
        <server host="sec2-hostname" port="1111"  />
     </pool>
     <region>...</region>
   <client-cache>

cache-cluster-3.xml 
   <client-cache>
     <pool name="clientCachePool" read-timeout="90000" >
        <server host="pri3-hostname" port="1111"  />
        <server host="sec3-hostname" port="1111"  />
     </pool>
     <region>...</region>
   <client-cache>

If I try to initialize separate ClientCache i get below error - > java.lang.IllegalStateException: A connection to a distributed system already exists in this VM.

ClientCache cc1 = ccf.set("cache-xml-file", "cache-cluster-1.xml").create(); 
ClientCache cc2 = ccf.set("cache-xml-file", "cache-cluster-2.xml").create(); 
ClientCache cc3 = ccf.set("cache-xml-file", "cache-cluster-3.xml").create();

如何使用 ClientCache 发布到这三个独立的集群?

在一个 JVM 中不能有多个 Cache 实例,这是因为它在内部作为 singleton 工作。此外,非常不鼓励将一个客户端连接到多个分布式系统,因为您可以 运行 解决其他问题,特别是不兼容 类 定义 and/or 命名空间冲突。

但是,GemFire/GEODE 附带了一个嵌入式机制来实现此用例:Multi-site (WAN) Configuration,它基本上允许您在不同的、松散耦合的分布式系统之间水平扩展。

希望对您有所帮助。

最好的问候语

在打开 cc2 之前关闭 cc1,在打开 cc3 之前关闭 cc2。

如果你真的必须访问其他集群中的数据,那么: - 如果您需要来自其他集群区域的所有数据,请考虑 WAN 网关 - 如果您只需要从另一个集群中的区域中选择数据,请考虑 CQRS 设计,其中您有另一个进程 运行 针对远程集群的 CQ(连续查询)并使用结果更新您的近集群。