问题
Related to this question I've setup a Spring Data Geode Client application with
@EnableClusterDefinedRegions(clientRegionShortcut=ClientRegionShortcut.CACHING_PROXY)
and by ensuring all classes are autowired then using the @Resource
the Geode server regions are setup and instantiated on the client.
@Resource(name = "request")
private Region<String, Request> request;
I can put and get on the regions like this. However when I try and register interest in a key on the server the updates from other clients to the server are received by the spring boot client. The register interest code:
request.registerInterestForAllKeys();
request.getAttributesMutator().addCacheListener(new myListener());
The logs show the interest is added to the region:
DEBUG [main] org.apach.geode.inter.cache.GemFireCacheImpl 4388 registerInterestStarted: registerInterestsStarted: new count = 1
TRACE [main] org.apach.geode.inter.InternalDataSerializer 2194 basicWriteObject: basicWriteObject: KEYS_VALUES
TRACE [main] org.apach.geode.inter.InternalDataSerializer 1535 writeDSFID: writeDSFID 37 class=class org.apache.geode.internal.cache.tier.sockets.InterestResultPolicyImpl
TRACE [main] org.apach.geode.cache.clien.inter.OpExecutorImpl 568 executeOnQueuesAndReturnPrimaryResult: sending org.apache.geode.cache.client.internal.RegisterInterestOp$RegisterInterestOpImpl@5e1a7d3 to backups: []
TRACE [main] org.apach.geode.cache.clien.inter.OpExecutorImpl 584 executeOnQueuesAndReturnPrimaryResult: sending org.apache.geode.cache.client.internal.RegisterInterestOp$RegisterInterestOpImpl@5e1a7d3 to primary: Connection[1.2.3.4:40404]@613231852
TRACE [main] org.apach.geode.cache.clien.inter.AbstractOp 85 attemptSend: Sending op=RegisterInterestOp$RegisterInterestOpImpl using Connection[1.2.3.4:40404]@613231852
When another client adds or changes a value on the server region that event is not getting to the spring boot client. The CacheListenerAdapter with usual afterCreate
and afterUpdate
overrides is not called.
The use case is to register and unregister to lots of different keys on the fly.
If I use the spring boot app itself to put to the local region, then the event handler is being called. So it's not an issue with the spring boot code this is a connection pool & server registration issue of some kind.
回答1:
The problem was my application.properties
had
spring.data.gemfire.cache.client.durable-client-id=myListener
For some reason a durable client cannot run a CacheListenerAdapter
来源:https://stackoverflow.com/questions/60226331/spring-data-geode-register-interest-is-not-receiving-events