5 Replies Latest reply on Oct 15, 2015 3:52 AM by rvansa

    Infinispan as 2lc of hibernate in wildfly cluster possible?

    klchan.kalam

      Hi all, as titled I am going to use Infinispan as 2lc of hibernate in Wildfly cluster, I thought it should not be a problem until i see this in infinispan doc:

       

      For all entities and collections, whenever a new entity or collection is read from database and needs to be cached, it’s only cached locally in order to reduce intra-cluster traffic. This option cannot be changed.

       

      I also see 'replicated-entity' which could be what i'm looking for, where can I find more info about it?

       

      My intention is to make some column of a table always available in infinispan for fast access, across wildfly cluster.

        • 1. Re: Infinispan as 2lc of hibernate in wildfly cluster possible?
          rvansa

          First of all, the documentation would deserve an update, given that it is still mentioning Hibernate 3.5 while 4.x branch is already at the end of maintenance cycle and you should definitely use version 5.0, which contains a lot of bugfixes wrt 2LC (see Infinispan: Hibernate Second Level Cache improvements). If you use 4.x, expect occasional stale reads.

           

          Anyway, the replicated-entity cache means that the updates will be replicated as key+value (as you're used to with replicated cache). Caching DB reads, on the other hand, uses special flags to keep the update local only. That way, you end up with nulls on one node and actual value on another - but that's safe wrt consistency with DB.

          • 2. Re: Infinispan as 2lc of hibernate in wildfly cluster possible?
            klchan.kalam

            Thanks Radim, is there a way to replicate updated entries to other nodes of infinispan?

            My intention is to keep whole table in every node for fast access, so say node 1 have an entry updated, i would like this update to replicate to other nodes as well.

            • 3. Re: Infinispan as 2lc of hibernate in wildfly cluster possible?
              rvansa

              In 4.x: When you execute INSERT INTO xxx VALUES (...), in replicated cache the value will get to the other nodes. Only when you do SELECT x FROM xxx, the cached result gets written only locally.

              In 5.0: When you use non-transactional replicated/distributed cache, in fact it replicates the cached result to other nodes, too. It was meant to work only locally as in previous version, but due to the way how Infinispan uses locking, it does not work and it's replicated to the other nodes as well. However, if it encounters a lock on any node, the update immediately silently fails instead of waiting for the lock.

              • 4. Re: Infinispan as 2lc of hibernate in wildfly cluster possible?
                klchan.kalam

                Thanks i see my wildfly 9 is using infinispan 7.2.3, i suppose it has the same behavior as 5.0?

                • 5. Re: Infinispan as 2lc of hibernate in wildfly cluster possible?
                  rvansa

                  Version of Infinispan used in WF for session replication is probably different from what ORM uses. AFAIK WF 9 uses Hibernate 4.3.x, and that was compiled against Infinispan 6. Albeit, it's possible that they're actually running Hibernate 4.3.x against 7.2.3 - WF 10 uses Hibernate 5.0.x with Inifinispan 8.0.x, although 5.0.x is still compiled against Infinispan 7.2.x.

                   

                  So, looks like you use 4.3.