Spring boot GemFire-Spring启动配置
我正在从事一个项目,有一个消防要求。 我找不到关于如何使用Spring Boot配置gemFire的正确教程 我已经创建了一个分区区域,我也想配置定位器,但我只需要服务器端配置,因为客户端由其他人处理 我是一个新手,真的很困惑。我曾尝试创建一个Spring boot GemFire-Spring启动配置,spring-boot,spring-data-gemfire,Spring Boot,Spring Data Gemfire,我正在从事一个项目,有一个消防要求。 我找不到关于如何使用Spring Boot配置gemFire的正确教程 我已经创建了一个分区区域,我也想配置定位器,但我只需要服务器端配置,因为客户端由其他人处理 我是一个新手,真的很困惑。我曾尝试创建一个cache.xml,但后来不知何故创建了一个cache.out.xml,出现了许多问题 普里扬卡- 最好从spring.io上的指南开始。具体来说,看看 “” 还有 “”和 “” 然而,这些指南主要关注“客户端”应用程序问题、“数据访问”(超过REST)、
cache.xml
,但后来不知何故创建了一个cache.out.xml
,出现了许多问题 普里扬卡-
最好从spring.io上的指南开始。具体来说,看看
“”
还有
“”和
“”
然而,这些指南主要关注“客户端”应用程序问题、“数据访问”(超过REST)、“缓存”等
尽管如此,您仍然可以使用Spring数据GemFire(甚至在Spring引导应用程序中)来配置GemFire服务器。我有很多这样的例子。特别是一个
“”
此示例演示如何将Spring引导应用程序引导为GemFire服务器(从技术上讲,是集群中的对等节点)。此外,GemFire属性由Spring配置指定,可以使用Spring的常规约定(属性占位符、SpEL表达式)来配置这些属性,如
这种特殊的配置使GemFire服务器成为一个“GemFire管理器”,可能带有一个嵌入式“定位器”(由start Locator
GemFie属性指示,不要与允许我们的节点加入和“现有”集群的“定位器”GemFire属性混淆),以及一个为GemFire缓存客户端服务的服务器(使用ClientCache
)
本例创建了一个,带有一个(定义)来填充缓存未命中的“阶乘”区域
由于此示例在Spring Boot GemFire Server应用程序进程中启动了嵌入式GemFire管理器,因此您甚至可以使用Gfsh连接到它,如下所示
gfsh>connect--jmx管理器=localhost[1099]
然后,您可以在“阶乘”区域上运行“get”,以查看它计算您给它的数字键的阶乘
要查看更高级的配置,请查看我的其他repo,特别是Contacts应用程序RI()
希望这有帮助
-John好吧,我也遇到了同样的问题,让我与大家分享一下我的工作原理,在本例中,我使用Spring Boot和Pivotal GemFire作为缓存客户端
locator1
),一个服务器(server1
)和一个区域(region1
)gfsh
),然后转到定位器文件夹并打开日志文件,在该文件中可以获取定位器正在使用的端口main
方法添加@enablegmfirecaching
注释@Cacheable(“region1”)
注释@Bean
ClientCacheFactoryBean gemfireCacheClient() {
return new ClientCacheFactoryBean();
}
@Bean(name = GemfireConstants.DEFAULT_GEMFIRE_POOL_NAME)
PoolFactoryBean gemfirePool() {
PoolFactoryBean gemfirePool = new PoolFactoryBean();
gemfirePool.addLocators(Collections.singletonList(new ConnectionEndpoint("localhost", HERE_GOES_THE_PORT_NUMBER_FROM_STEP_4)));
gemfirePool.setName(GemfireConstants.DEFAULT_GEMFIRE_POOL_NAME);
gemfirePool.setKeepAlive(false);
gemfirePool.setPingInterval(TimeUnit.SECONDS.toMillis(5));
gemfirePool.setRetryAttempts(1);
gemfirePool.setSubscriptionEnabled(true);
gemfirePool.setThreadLocalConnections(false);
return gemfirePool;
}
@Bean
ClientRegionFactoryBean<Long, Long> getRegion(ClientCache gemfireCache, Pool gemfirePool) {
ClientRegionFactoryBean<Long, Long> region = new ClientRegionFactoryBean<>();
region.setName("region1");
region.setLookupEnabled(true);
region.setCache(gemfireCache);
region.setPool(gemfirePool);
region.setShortcut(ClientRegionShortcut.PROXY);
return region;
}
@Bean
ClientCacheFactoryBean gemfireCacheClient(){
返回新的ClientCacheFactoryBean();
}
@Bean(name=GemfireConstants.DEFAULT\u GEMFIRE\u POOL\u name)
PoolFactoryBean gemfirePool(){
PoolFactoryBean gemfirePool=新的PoolFactoryBean();
gemeFirePool.addLocator(Collections.singletonList(新的ConnectionEndpoint(“localhost”,这里是“端口号”),来自“步骤4”);
setName(GemfireConstants.DEFAULT\u GEMFIRE\u POOL\u NAME);
gemfirePool.setKeepAlive(假);
gemfirePool.设置间隔(时间单位为秒,单位为5);
GemeFirepool.setRetryAttempts(1);
gemfirePool.setSubscriptionEnabled(true);
gemfirePool.setThreadLocalConnections(false);
返回Gemool;
}
@豆子
ClientRegionFactoryBean getRegion(ClientCache gemfireCache、Pool GemFireTool){
ClientRegionFactoryBean区域=新ClientRegionFactoryBean();
region.setName(“region1”);
region.setLookupEnabled(true);
region.setCache(gemfireCache);
区域。设置池(gemfirePool);
region.setShortcut(ClientRegionShortcut.PROXY);
返回区;
}
仅此而已!也不要忘记序列化(implements Serializable
)正在缓存的类(缓存方法返回的类)此外,我不能使用gfsh命令,我需要有属性文件或硬编码。