Intro
Continuing the topic on jdg quick-starts, the next would be CarMart-tx, so a bit of transactions on the game. As before, I would recommend to read the configuration with the latest User Guide in another tab.
What is different than CarMart
Pretty much everything similar to CarMart, however, now with the TX part.
First difference will be:
.jmxDomain(“org.infinispan.carmart.tx”)
.defaultCacheName(“default”)
The first line pretty much give a jmxDomain so it won’t colide with the other tutorial carMart. The second, actually give a name to the cache.
And of course, the core difference, in the cache configuration:
.transaction().transactionMode(TransactionMode.TRANSACTIONAL).autoCommit(false)
.lockingMode(LockingMode.OPTIMISTIC).transactionManagerLookup(new GenericTransactionManagerLookup())
.memory().size(4).evictionType(EvictionType.COUNT)
Breaking down the configuration – which is pretty straighforward:
- added .transaction():: enables the tx part
- transactionMode(TransactionMode.TRANSACTIONAL):: set to transational instead of non_transactional
- autoCommit(false)::
- lockingMode(LockingMode.OPTIMISTIC)::
- transactionManagerLookup(new GenericTransactionManagerLookup():: the lookup needs to be set because the mode is transactional.
- .memory replaces .eviction – which was deprecated
So there you have it: the transactions is now a partof the BasicCacheContainer. More info here.
Interesting topics
- See Reference for book – the discussion of pessimistic and optimistic is very interesting [1]. As well as the version differences. Will do another post about it
- When using declarative (and not programming way) the scheme is always welcomed.
- Deployment
INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool — 96) Initializing Mojarra 2.3.9.SP05 for context ‘/jboss-carmart-tx’
4. The warning < ISPN000435: Cache manager initialized with a default cache configuration but without> didn’t appear – 😀
5. Testing with a new DummyTransactionManagerLookup() based on this StackOverflow doesn’t work, cause it is deprecated. Use Embedded instead.
6. On Maven: use <compilerArgument>-Xlint:unchecked</compilerArgument> or
<compilerArgument>\n-Xlint:deprecation\n</compilerArgument>
Reference
[1] This part of Transnationals/Non-Transactional is described with details on the Book: Infinispan Data Grid Platform Definitive Guide, written by a fellow compatriot that lives in Dublin – Wagner Roberto Dos Santos. This part is described on chapter Understanding Transactions and Concurrency.