ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kevin <kevin.c...@leonardo.com>
Subject Re: CacheStore implementation using Hibernate
Date Tue, 22 Sep 2015 22:31:54 GMT
I also found the other behavior that's been giving me confusing results:
For both CacheInterceptor and CacheEntryProcessor, the onBeforePut/process
methods are called twice. Once on IgniteCache.put/invoke and once on
Transaction.commit.

Consider this code

>         tx = ignite.transactions().txStart();
>         int[] arg = {1};
>         cache.invoke("test1", new CacheEntryProcessor
> &lt;
> String, TestValue, Void
> &gt;
> () {
>             @Override
>             public Void process(MutableEntry
> &lt;
> String, TestValue
> &gt;
>  entry, Object... args) throws EntryProcessorException {
>                 int arg = ((int[]) args[0])[0];
> 
>                 TestValue val = entry.getValue();
> 
>                 val.setMyInt(val.getMyInt() + arg);
>                 entry.setValue(val);
> 
>                 return null;
>             }
>         }, arg);
>         System.out.println("before commit: " + cache.get("test1"));
>         arg[0] = 5;
>         tx.commit();
> 
>         System.out.println("after commit: " + cache.get("test1"));

To the developer, the cache value would've looked like it incremented by 1
before it commits. The action of calling tx.commit() intuitively means to
flush the changes to the database. Instead, the cache processor runs again,
and the actual commit to the database increments the value by 5.

Another thing is that if the CacheEntryProcessor executes successfully the
first time, but throws a EntryProcessorException during commit, this error
looks like it gets suppressed silently and the write through doesn't occur.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/CacheStore-implementation-using-Hibernate-tp1423p1465.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message