Announcement Announcement Module
Collapse
No announcement yet.
Problems with spring gemfire client region Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with spring gemfire client region

    Hi,

    I'm using spring gemfire version 1.1.0.RELEASE for Java.
    I've run into a problem with a client region when I moved from gemfire xml and lookup region to spring gemfire context. In my client xml file I defined a client region:
    client.xml:
    Code:
    <?xml version="1.0"?>
    <!DOCTYPE cache PUBLIC
      "-//GemStone Systems, Inc.//GemFire Declarative Caching 6.5//EN"
      "http://www.gemstone.com/dtd/cache6_5.dtd">
    <cache>
      <pool name="client" subscription-enabled="true">
        <locator host="[locator.host]" port="[locator.port]"/>
      </pool>   
      <region name="my_region">
        <region-attributes scope="local"/>
      </region>
    </cache>
    cache-context.xml:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:gfe="http://www.springframework.org/schema/gemfire"
    	xmlns:p="http://www.springframework.org/schema/p"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:util="http://www.springframework.org/schema/util"
    	xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
    		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
    		
    	<gfe:cache id="gemfire-cache" cache-xml-location="classpath:client.xml" properties-ref="props" />
    	
    	<util:properties id="props" location="file:config/gemfire-config.properties"/>
    
    	<gfe:lookup-region id="my_region" name="my_region"/>
    	
    	<bean id="GemfireTemplate" class="org.springframework.data.gemfire.GemfireTemplate" p:region-ref="my_region"/>
    </beans>
    when I run this configuration everything is as expected i.e. I can see the contents of the cache and all the changes done by the client are visible only in the client's cache.
    When I moved my config to spring gemfire context file:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:gfe="http://www.springframework.org/schema/gemfire"
    	xmlns:p="http://www.springframework.org/schema/p"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:util="http://www.springframework.org/schema/util"
    	xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
    		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
    	
    	<gfe:client-cache id="gemfire-cache" pool-name="connection-pool" properties-ref="props" />
    	
    	<util:properties id="props" location="file:config/gemfire-config.properties"/>
    
    	<gfe:pool id="connection-pool" subscription-enabled="true">
    	    <gfe:locator host="${locator.host}" port="${locator.port}"/>
    	</gfe:pool>
    
    	<gfe:client-region id="my_region" name="my_region" pool-name="connection-pool">
    		<gfe:cache-listener>
    			<bean class="com.nomura.fiet.crossproduct.gf.CacheOperationLogger"/>
    		</gfe:cache-listener>
    		<gfe:regex-interest pattern=".*" receive-values="true"/>
    	</gfe:client-region>
    	
    	<bean id="GemfireTemplate" class="org.springframework.data.gemfire.GemfireTemplate" p:region-ref="my_region"/>
    </beans>
    Changes done on the client side are propagated to the cache. I've debugged both cases and scope field in region object is set to LOCAL scope in each case.
    Can you advise why the changes from local region are propagated to the cache servers, please? Has anyone run into the same problem?

    Cheers,
    Dariusz

  • #2
    Hi Dariusz,

    I have experienced something similar in an earlier version of Spring Gemfire. I cannot remember if the pool-name is a mandatory attribute on the client-region. Could you try and remove leave the pool-name off the client-region? As your original client setup does not explicitly link the client-region to the pool as in your upgrade version you do.

    I have a sneaky suspicion that if you set a pool-name on a region, the system will try and write to the pool, regardless of scope setting.
    Last edited by Udo; Feb 5th, 2012, 10:55 PM.

    Comment


    • #3
      Hi Udo,

      That seems to do the trick. Similar behaviour is observed with gemfire xml if you specify pool-name in region attributes i.e. writes are no longer local.
      Unfortunately if I try to register an interest on the region (that’s why I wanted to use spring-gemfire's client-region in first place. I couldn’t find a way to do interests registration in gemfire xml) I get:
      Code:
      java.lang.UnsupportedOperationException: Interest registration requires a Pool
      You mentioned:
      I have a sneaky suspicion that if you set a pool-name on a region, the system will try and write to the pool, regardless of scope setting.
      Which seems to be right for both cases lookup-region with gemfire xml and client-region with spring-gemfire configuration. Unfortunately if you don't have the pool specified you can't have an interest in spring gemfire. Hence you can't filter on the contents of the cache.
      Another problem with client-region is when you try to name your pool with a different name than 'connection-pool'. Then you are getting:
      Code:
      org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'connection-pool' is defined
      Can you advise please?
      Cheers,
      Dariusz

      Comment

      Working...
      X