2 Replies Latest reply on Oct 22, 2007 3:07 AM by spennec

    How TreeCacheListener works

    spennec

      Hello,

      I'm trying to use a TreeCacheListener in the following situation:

      - TreeCache version: 1.4.1 SP4
      - There is a cluster with two members
      - TreeCache is in mode INVALIDATION_SYNC and OPTIMISTIC locking scheme

      When a piece of data is modified, I remove it from the cache. I expect the corresponding data to be invalidated in the other cluster member.

      What I would like to do is recieve a call in the listener on cluster member A (and optionnaly B) when some piece of data is removed from cluster member B. Is that possible?

      To register the listener, I've just created a subclass of AbstractTreeCacheListener, and called the following method, before calling the start() method:

      treeCache.addTreeCacheListener(listener);


      At this point, I've added logs in several methods, and some of them, that I expect to be called, remain silent. Here are the methods I've implemented, and only filled with logs:


      nodeRemoved
      nodeRemove
      cacheStarted
      cacheStopped
      nodeEvict
      nodeEvicted


      The methods cacheStarted and cacheStopped are called. But the other are never called, on any cluster member, even when I call remove() on the treeCache to invalidate some data.

      Am I not understanding the goal of the TreeCacheListener? Or did I do something wrong with the setup?

      Thanks a lot for your help!

        • 1. Re: How TreeCacheListener works
          manik

          Your understanding is correct and you should get notifications. Do you get them with other cache modes, like REPL_SYNC?

          • 2. Re: How TreeCacheListener works
            spennec

            Thanks for your reply, Manik! :)

            I think my understanding may not be correct after all: at the time, I was trying to recieve a notification when a pair key-value was removed from inside a given node. And this is not possible, is it correct?

            I now create a new node for each of my data and remove the node, which triggers the notifications correctly.