1 Reply Latest reply on Oct 26, 2006 12:37 AM by Ben Wang

    PojoCache replcation not working

    guava Newbie


      I'm on JBossCache 1.4.0.SP1. I'm just testing pojo cache replication between two machines. I wrote a simple test case and a pojo class. I started the test on one machine and put the object into the cache. I then started the second machine and the initial state did get replicated over.

      However, when I modified the pojo on the first machine I never saw the modification got replicated. Below is my code. Maybe I'm making some simple mistake? Thanks for any help.

      Test case:
      public class Driver
      static Logger logger = Logger.getLogger(Driver.class);

      public static void main(String[] args)
      try {
      PojoCache cache = new PojoCache();
      PropertyConfigurator configurator = new PropertyConfigurator();
      configurator.configure(cache, new FileInputStream("jboss-cache.xml"));
      cache.addTreeCacheListener(new Driver());

      //this is the code executed on the first machine
      Router r0 = new Router(0, "12:34:56:78:FF:00");
      cache.putObject("/router", r0);

      //this is the code on the second machine. I simply get that pojo from the cahce
      //Router r0 = (Router)cache.getObject("/router");

      // start a thread to display the router every 3 seconds
      // never saw the change got replicated to the second machine!
      DisplayThread display = new DisplayThread();
      new Thread(display).start();

      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

      //start a loop to insert new address into the POJO
      while ( true ) {
      System.out.print("Enter ip...");
      String line = reader.readLine();

      } catch ( Throwable tx ) {
      public class Router
      private List addresses;
      private int id;
      private String mac;

      public Router()


      public Router(int id, String mac)
      this.id = id;
      this.mac = mac;
      addresses = new ArrayList();

      public List getAddresses()
      return addresses;

      public int getId()
      return id;

      public String getMac()
      return mac;

      public void addAddress(String address)

      public String toString()
      StringBuffer sb = new StringBuffer();
      sb.append("router ").append(id).append(" mac").append(mac).append("addresses:").append("\n");
      for ( String s: addresses ) {
      sb.append(s).append(" ");

      return sb.toString();