I have a region configured with both a gateway listener and a cache loader
<gateway-hub id="testHub" port="-1" startup-policy="none">
<gateway id="testHub">
<gateway-listener>
<class-name>com.demo.WriteBehindListener</class-name>
</gateway-listener>
<gateway-queue batch-size="50" batch-time-interval="10000"/>
</gateway>
</gateway-hub>
<region name="testRegion">
<region-attributes enable-gateway="true" hub-id="testHub">
<cache-loader>
<class-name>com.demo.Loader</class-name>
</cache-loader>
<eviction-attributes>
<lru-memory-size maximum="100"/>
</eviction-attributes>
</region-attributes>
</region>
I have noticed that when the cache loader gets called for a cache miss, this eventually causes a CREATE operation to be delivered to the gateway listener as the entry is placed into the cache.
However i have noticed that the operation is always set to Create and not LOCAL_LOAD, as a result i am ending up with duplicate entries in my database as i have the following simple logic to handle the operation:
if (operation.isCreate()) {
genericDAO.save(entity);
}
}
else if(operation.isDestroy()) {
genericDAO.delete(entity);
}
}
else if(operation.isUpdate()) {
genericDAO.save(entity);
}
}
In the GatewayEventListener how do you distinguish between an entry placed into a region that has resulted from a cache load ?
operation.isLoad() // always returns false
operation.isLocalLoad() // always returns false
Am i missing some configuration in the gateway or region ?