1 Reply Latest reply on Nov 10, 2014 11:07 AM by william.burns

    Infinispan replication mode - make sure only single node do some logic

    nir77

      Hi,

      I am using a replicaton cache mode with cluster has 2 nodes

      I am put an object to infinispan cache , and on Listener class have method with @CacheEntryCreated which call dao class for persist the object to database .

       

      Question

      1)I can I make sure that only single node is executing the dao logic which save the entity to database?

      2) can I in some configuration explicit chose the owner node , and just in case of any node failure ownership is moved to second cluster node ?

       


        • 1. Re: Infinispan replication mode - make sure only single node do some logic
          william.burns

          It sounds like what you really want is a CacheWriter not a CacheListener.  Our internal docs on CacheLoader and CacheWriters are found at Infinispan User Guide.  You could try using the JPAStore or use one of the various JDBC cache stores that are provided.

           

          If you can't support the JPAStore or have to have your own schema you can always write your own writer/loader.  Note that a writer and loader are independent and your implementation doesn't need to implement both interfaces.  Some good examples to start from are the SingleFileStore fond at ISPN/src/main/java/org/infinispan/persistence/file/SingleFileStore.java or DummyInMemoryStore found at ISPN/src/test/java/org/infinispan/persistence/dummy/DummyInMemoryStore.java

          1 of 1 people found this helpful