1 Reply Latest reply on Mar 29, 2012 2:45 PM by 694204

    Unable to get NamedCacheLifecycleEvent events fired. Coherence 3.6


      I have a namespace content handler (based on an IndexHandler sample I found on the forums). However in my case rather than a NamedCacheStorageRealizedEvent I want to be notified when a Cache is started and then pass in some information from my extensible XML to a scheduler that will schedule at a fixed rate the class specified (in order to pick up new data from a DB and load into the cache). However I seem unable to set the filter correctly. I can pick up NamedCacheStoredRealizedEvents fine but this is not what I want as I get loads of them for all the coherence common/processing pattern caches.

      The code in the Element Handler is (edited for brevity) :-

      registerContentHandler("task", new ElementContentHandler()
                     public Object onElement(ConfigurationContext configurationContext,
                                                   QualifiedName qualifiedName,
                                                   XmlElement xmlElement) throws ConfigurationException {
                          EventDispatcher eventDispatcher = configurationContext.getEnvironment().getResource(EventDispatcher.class);
                eventDispatcher.registerEventProcessor(new NamedCacheLifecycleEventFilter("mars-data-mars-commodity"), new MyTask());
                          return null;

      The config of the cache is:-


      <local-storage system-property="mars.localstorage">true</local-storage>

      I have tried also trying the wildcards for the filter:-

      eventDispatcher.registerEventProcessor(new NamedCacheLifecycleEventFilter("*"), new MyTask());

      This also does not work. Has anyopne managed to get this to work. Or else has a better idea for how to create and schedule tasks for repeatable (fixed period)
      execution by specifying them in the extensible environment please let me know !.

      My idea was to have the class names specified int he XML with the refresh period and then have them instantiated by reflection and then use
      the ScheduleExecutorService.scheduleAtFixedRate() to have the tasks then fired and submitted to the Processing Parttern to have them executed
      in the grid. But I cannot prevent the Task Scheduler being invoked mulutiple times from the Extensible Environment !!.

      Any help appreciated !.


      Edited by: jedizippy on Mar 29, 2012 6:01 AM

      Edited by: jedizippy on Mar 29, 2012 7:45 AM
        • 1. Re: Unable to get NamedCacheLifecycleEvent events fired. Coherence 3.6
          Note I tried using both the following values:-

          eventDispatcher.registerEventProcessor(new NamedCacheLifecycleEventFilter("MarsData"), new MyTask());
          eventDispatcher.registerEventProcessor(new NamedCacheLifecycleEventFilter("mars-data-mars-commodity"), new MyTask());

          I also changed the names to make sure I was not having issues with RegEx etc. But none of these methods works. In the logging from coherence and the processing pattern I can see the LifecycleStartedEvent and NamedCacheStorageRealizedEvent but the one I want NamedCacheLifecycleEvent is never seen in the logs so I can only assume that it is not implemented ?.

          At this point I give up.

          Edited by: jedizippy on Mar 29, 2012 7:44 AM