How to know an object is replicated?

Developers
2009-09-04
2013-05-14
  • Minoru Nitta

    Minoru Nitta - 2009-09-04

    Hi,

    I am implementing distributed object replication with ehcahce, and I have a question.

    I would like to be notified when an object is newly replicated from other peers.
    I looked at JavaDoc but it seems to me that it is not possible to implement such
    program.

    Does anyone know how to do that? Is there any listener interface to implement?

    Thank you.

    Minoru

     
    • Andrew Liles

      Andrew Liles - 2009-09-04

      AFAIK you are correct; you can listen to cache put events (see http://ehcache.org/documentation/cache_event_listeners.html\)  but you cannot distinguish that they came from a peer or the current cache.  However this is easily achieved, here are two options for you to consider:

      1. Make the value passed in the Element are rich object that includes the identifier of the JVM/host/peer that created the data.  Therefore, having been notified about a cache put, you could distinguish whether it came from "itself".

      2. If you are using JMS replication, this is implemented using a JMS topic.  JMS topics can be listened to by any number of clients - the ehcache implementation adds a listener per Cache Manager.  You could implement your own listener, quite outside of Ehcache, and notice when data is being replicated.  (Same problem as in 1 - if you wish to notice that the replication was caused by a remote peer, you need to pass an attribute in the Element's value object).

       
    • Minoru Nitta

      Minoru Nitta - 2009-09-07

      Hi Andrew

      Thank you for your thoughtful ideas. I didn't notice that.
      I'll try to do that.

      Minoru

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks