Search code examples
gemfirespring-data-gemfire

Gemfire Subscription does not work on distributed environment


I setup a cluster Gemfire environment with 2 locators and 3 nodes. I would like to use it as a publisher/subscription solution. I create a cache-listener in the Java application and it works well(logging) when I insert an item into a region. However, then I start a gfsh window to insert an item, the java listerner dose not work. My configuration is below:

 <gfe:client-cache id="client-cache" pool-name="my-pool" properties-ref="gemfire-props"/>
 <gfe:pool id="my-pool" subscription-enabled="true">
         <gfe:locator host="10.151.134.111" port="10334" /> 
    </gfe:pool>
    <gfe:client-region id="Test" data-policy="EMPTY" cache-ref="client-cache">
         <gfe:cache-listener> 
           <bean class="Test.util.LoggingCacheListener"/> 
        </gfe:cache-listener>       
    </gfe:client-region>

Solution

  • I believe you need data-policy=NORMAL (or something other than EMPTY) for this to work. See DataPolicy for more details. The client listener will not fire because data is never replicated to the client cache, so there is no state change. With data-policy=EMPTY, the listener will fire only if a put is executed by the client.