Pojo Cache EvictionPolicy event?
sinjem Jul 23, 2009 3:00 PMI'm looking for a JBoss Pojo Cache listener event that I can wire in to my code to get called when a timeToLiveSeconds in my EvictionPolicyConfig gets fired.
I've found the @PojoCacheListener but don't get an event fired when the the node is removed. After my junit test the objects are gone but my event listener is never fired.
I've added listeners for @NodeEvicted, @NodePssivated, @NodeInvalidated, and @Detached but my method does't get fired when a node is removed based on my local-service.xml eviction policy. The objects are gone but my listener method never gets fired.
Here's my policy xml:
<attribute name="EvictionPolicyConfig"> <config> <attribute name="wakeUpIntervalSeconds">5</attribute> <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute> <!-- JUnit Test Supplied Region --> <region name="/_default_"> <attribute name="maxNodes">5000</attribute> <attribute name="timeToLiveSeconds">3</attribute> </region> </config> </attribute>
And here's my event listener:
@PojoCacheListener public class JBossPojoDataStoreListener { private static Log log = LogFactory .getLog(JBossPojoDataStoreListener.class); @Attached @Detached @NodeEvicted @NodePassivated @NodeRemoved @NodeInvalidated public void handleAttachDetach(Event event) { if (event instanceof AttachedEvent) { log.debug("Attached = " + event.getSource()); } else if (event instanceof DetachedEvent) { log.debug("DetachedEvent = " + event.getSource()); } else if (event instanceof NodeEvictedEvent) { log.debug("NodeEvictedEvent = " + ((NodeEvictedEvent) event).getFqn()); } else if (event instanceof NodePassivatedEvent) { log.debug("NodePassivatedEvent = " + ((NodePassivatedEvent) event).getFqn()); } else if (event instanceof NodeRemovedEvent) { log.debug("NodeRemovedEvent = " + event.getSource()); } else if (event instanceof NodeInvalidatedEvent) { log.debug("NodeInvalidatedEvent = " + ((NodeInvalidatedEvent) event).getFqn()); } } }
Am I missing something insanely obvious? Has anyone had any luck getting this to work?
Thanks for any experience you can share.
-Jeff