Reputation: 5698
I am considering to use Infinispan as a replacement for my relational database in wildfly.
CDI supports the @Transactional
annotation. Normally, I put @Transactional
on method level only for JPA related transactions. Will infinispan make use of @Transactional
(with its Java Transaction API). Or is @Transactional
only for JPAs?
Upvotes: 1
Views: 725
Reputation: 5213
Yes, Infinispan supports JTA and CDI supports JTA too, so when the CDI's Transaction Interceptor execute, it will take the Transaction Manager and create a transaction. If your Infinispan cache has configured this Transaction Manager, the resource will be enlisted/syncrhonized to the transaction.
You need to configure a TransactionManager to Infinispan like documentation says (Infinispan ships with several transaction manager lookup classes that can helps). For more info about this: (Infinispan doc reference).
Take in mind that if you wish to mix in a same transaction multiple resources like a database and a cache and you wish to do this in a single transaction, Infinispan supports distributed transactions too so you can configure a XA transaction (in that case your database or other resource must to support XA too). More information about this: Infinispan doc reference 2 and Infinispan doc reference 3
Upvotes: 2