6 Replies Latest reply on Jan 13, 2011 5:50 AM by galder.zamarreno

    cacheEntryModifiedEvent isPre (false) problem

    jcmorgan08

      Hi,

       

      I have a replicated inmem cache and I'm trying to call a method when a value is updated in the cache, however, I only get null values. The problem is illustrated with this code:

       

              @CacheEntryModified

              public void cacheEntryModified(final CacheEntryModifiedEvent e) {

                  System.out.println("Mod a entry to cache... pre = " + e.isPre() + " local = " + e.isOriginLocal() + " key = " +                                 e.getKey().toString());

                  if (!e.isPre()) {

                      Cache c = e.getCache();

                      System.out.println(c.getName());

                      showCurrentValue(e, c);

                      System.out.println("mod value(2) = "+e.getValue());

                      showCurrentValue(e, c);

                  }

              }

       

              private void showCurrentValue(final CacheEntryModifiedEvent e, Cache c) {

                  Object o = c.get(e.getKey().toString());

                  if (o != null)

                      System.out.println("mod value = " + o.toString());

                  else

                      System.out.println("mod value = NULL");

              }

       

       

      When the key "hello" is updated to value "www" I get this output:

       

      Mod a entry to cache... pre = false local = true key = hello

      replicatedInmem

      mod value = NULL

      mod value(2) = www

      mod value = NULL

       

      Now, that's all well and good, I can get the new value by calling "e.getValue()" - but I was expecting, since this is a post event, to be able to get the value by querying the cache. As a "post modification" event, shouldn't that be the case?