假設我的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