2 Replies Latest reply on Mar 10, 2013 1:17 PM by verystrongjoe

    How can I make a one transaction with two named caches?

    verystrongjoe

      Hi, I have a lot of interested in Infinispan and am happy for joining here.

      This is my first time when i write here. please help me

       

      The software that I want to make using infinispan is like FIFO queue with failover.

      So, it is not only in-memory-database, but also trigger business process with entry out from deque.

      and the nodes has 4 and each node has two named cache. One cache, pilotCache, is real data cache saving (Key, Value) type objects and

      the other cache, ketSetCache,  is for saving key, (Key, name of node where data of the key exists).

      And keySetCache is used when one of node is fail and the data have to be triggered again)

       

       

       


      <default>


      <transaction



      transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"



      lockingMode="OPTIMISTIC">


      </transaction>

      </default>



      <namedCache name="keySetCache">


      <clustering mode="repl"/>


      <jmxStatistics enabled="true"/>

      </namedCache>

       

       


      <namedCache name="pilotCache">


      <clustering mode="dist">



      <sync replTimeout="20000" />



      <hash numOwners="1"  />


      </clustering>


      <storeAsBinary enabled="true"  storeKeysAsBinary="true"  />

       

       



      <loaders passivation="false"  shared="true"   preload="true">





      <loader class="org.infinispan.loaders.jdbc.binary.JdbcBinaryCacheStore" fetchPersistentState="false"

                       ignoreModifications="false" purgeOnStartup="false">

                  <properties>

                     <property name="bucketTableNamePrefix" value="ISPN_BUCKET_TABLE"/>

                     <property name="idColumnName" value="ID_COLUMN"/>

                     <property name="dataColumnName" value="DATA_COLUMN"/>

                     <property name="timestampColumnName" value="TIMESTAMP_COLUMN"/>

                     <property name="idColumnType" value="VARCHAR(255)"/>

                     <property name="dataColumnType" value="BINARY"/>

                     <property name="timestampColumnType" value="BIGINT"/>

                     <property name="connectionFactoryClass" value="org.infinispan.loaders.jdbc.connectionfactory.SimpleConnectionFactory"/>

                     <property name="connectionUrl" value="jdbc:h2:tcp://localhost:4444/dbFile/cosmos;MODE=Oracle;DB_CLOSE_DELAY=-1"/>

                     <property name="userName" value="sa"/>

                     <property name="password" value="sa"/>

                     <property name="driverClass" value="org.h2.Driver"/>

                     <property name="dropTableOnExit" value="false"/>

                     <property name="createTableOnStart" value="true"/>

                  </properties>

               </loader>



      </loaders>

      </namedCache>

       

       

      1) I want to make two caches be in one transaction, but the configuration xml in infinispan have to set one transaction each cache.

      detaily, i have to guarantee that one entry have to enter two caches.

       

       

      2) If I set listener that sync is false and add one entry, then the entryCreatedEvent is invoked, and it failed..

      but I don't want to rollback. How can I configure for that?

        • 1. Re: How can I make a one transaction with two named caches?
          mircea.markus

          1) I want to make two caches be in one transaction, but the configuration xml in infinispan have to set one transaction each cache.

          detaily, i have to guarantee that one entry have to enter two caches.

          you'd have to make sure both cache are transactional and use the same transaction manager (have the same transaction manager lookup configured).

          then just fetch the TransactionManager from one cache(cache.getAdvancedCache().getTransactionManager(), start a transaction and then commit it.

           

          2) If I set listener that sync is false and add one entry, then the entryCreatedEvent is invoked, and it failed..

          but I don't want to rollback. How can I configure for that?

          Just catch the exception in the etryCreated and don't throw it to infinispan.

          • 2. Re: How can I make a one transaction with two named caches?
            verystrongjoe

            thank you very much for replying my question.

            it's very urgent problem for me. if you help me, i will appreciate very much

            so can I ask additional question? I'm not good at english. but i will do my best explaing my situation and goals. it is very long story.

             

            As far as I know, infinispan is in memory data base.

            but, in my case, I have to implement a queue (first in first out) and guarantee that any data must not lose. If one data lose, the system is very critical.

            I have to know incoming key as soon as one entry come in and call business procss with the key.

            So I had to use two kinds of listener and three jobs for recoevery and trigger business process for keys in FIFO way.

            I couldn't use numOwner as 2. because infinispan can't distinguish original and replicated entry and the listener of nodes where data enter invoke 2 times with same key.

            ( so business process called twice and it's duplicated),.

             

            Anyway, the listener has two kinds.
            one is attached to the data cache for saving real businiss data(key,value).

            the data cache is set invalidation mode and no replica and then, passivation is false. shared is true. and share one jdbc cache store.

            the other is attached to recovery info cache for saving (key, nodename).

            ( when one node is failed, I have to rebalancing datas of dead node with this info cache to new-member nodes in view change event )

             

             

            and each listener has a job like below.

            Fisrt, I attached listener of data cache for catching incoming keys,

            Second, I have to know which node received data and (DataKey, NodeName) data have save to replicated cache.

            and I have to trigger business process,  call get() to imdg( in memeory data grid ) and then call remove().   it's original process.

            Third, I have to implement viewChanged Event for invoking the job that reblance datas of failed node to other new-member node.

             

            If the content of this is lack for you, I will give more explanation with pictures. please help me