假设我的Gemfire定位器& cacheserver进程已经在我的目标部署环境中运行。目标部署环境使用client-server topology。Spring Data Gemfire配置没有连接到定位器?
我有一个Spring 3.1 MVC应用程序,它想要使用Gemfire缓存。我使用Spring数据的GemFire 1.2.2和6.6.1的GemFire
所以我增加了以下我spring.xml
<util:properties id="gemfire-props">
<prop key="log-level">${gemfire.log-level}</prop>
<prop key="mcast-port">${gemfire.mcast-port}</prop>
<prop key="locators">${gemfire.locators}</prop>
</util:properties>
<gfe:cache id="gemfireCache" properties-ref="gemfire-props"/>
<gfe:replicated-region id="myCacheRegion" cache-ref="gemfireCache">
<gfe:cache-listener>
<ref bean="gemfireCacheLogListener"/>
</gfe:cache-listener>
<gfe:entry-ttl timeout="${gemfire.myCacheRegion.ttl}" action="DESTROY"/>
</gfe:replicated-region>
<bean id="gemfireCacheLogListener" class="org.awong.GemfireCacheLogListener"></bean>
<bean id="cacheManager" class="org.springframework.data.gemfire.support.GemfireCacheManager"
p:cache-ref="gemfireCache">
<property name="regions">
<set>
<ref bean="myCacheRegion"/>
</set>
</property>
</bean>
假设外部JAR依赖关系都被正确定义,说,Maven。假设我有一个加载的属性文件,它定义了上面引用的属性值。 locators
属性定义为使用已启动的Gemfire定位器的IP和端口。
我相信这应该足够好,以便我可以在我的MVC应用程序中使用@Cacheable
注释bean。我希望这些配置可以启动应用程序服务器中的定位器以连接到Gemfire网格,将myCacheRegion
添加到Gemfire高速缓存服务器,然后cacheManager
应该能够使用新的高速缓存区域。
我得到它们由故障引起BeanCreationException
s到连接到定位器,当春天启动:
4-Mar-2013 16:02:08.750 SEVERE org.apache.catalina.core.ApplicationContext.log StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException:
[rest of stack trace snipped out]
nested exception is com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service. Operation either timed out or Locator does not exist.
Configured list of locators is "[hostnameOfLocator<v0>:portOfLocator]".
但是当我部署到目标环境中的GemFire豆失败是因为定位器创建进程无法连接。我错过了什么?
谢谢,戴夫! mcost-port设置为0.我已经排除了由SDGF 1.2.2加载的Gemfire。 我曾尝试使用连接到的Spring配置,该配置使用预期的定位器主机名和端口,但我仍然得到相同的异常。 –
Alan
2013-03-14 15:48:25
Dave,如果我只需要@Cacheable,那么我们可以使用Gemfire作为独立嵌入式缓存吗?我的客户坚持认为我们只使用Gemfire作为缓存提供者,而不是使用其他提供者,如EhCache。 – Alan 2013-03-14 16:05:47
另外我还浏览了github上的gemfire示例(https://github.com/SpringSource/spring-gemfire-examples),并在您使用SDGF 1.2.1时返回提交。我注意到replicated-cs示例具有与复制区域具有相同标识的客户端区域。如果它们处于相同的应用程序环境中,这不会造成问题,对吗? – Alan 2013-03-14 16:12:23