Configure Infinispan/Quarkus for transactions #50197
-
Hi, Example how I configure the cache and in Quarkus my DAO class has @transactional and my RemoteCache @Inject and @Remote("my-cache") annotated. I do not have any problems with getting or putting values into the cache, just couldn't figure out the transaction thing. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
/cc @karesti (infinispan), @radcortez (config), @wburns (infinispan) |
Beta Was this translation helpful? Give feedback.
-
@schall1337 let me check this and I come back to you |
Beta Was this translation helpful? Give feedback.
-
@schall1337 I think we miss an integration point with the tx caches in the Quarkus integration, but this might be for historical reasons. In any case, the DAO or adding Transactional in Quarkus won't work to make use of Infinispan tx in remote cache. |
Beta Was this translation helpful? Give feedback.
-
@schall1337 I'll open an issue to document and add an extra for transactional caches. @Inject
RemoteCacheManager manager;
// Add transaction config in the client too
manager.getConfiguration()
.addRemoteCache("mycache", c -> {
c.transactionMode(TransactionMode.FULL_XA);
});
// Don't inject the cache, but grab it from the manager
RemoteCache<String, Data> txMyCache = manager.getCache("txCache");
// TransactionManager should not be null now
TransactionManager transactionManager = txMyCache.getTransactionManager();
transactionManager.begin();
// Operations
transactionManager.commit(); |
Beta Was this translation helpful? Give feedback.
-
I created this issue and PR #50263 |
Beta Was this translation helpful? Give feedback.
-
thanks for the fast reply and implementation! Tried the workaround and works for the quarkus version I am using. |
Beta Was this translation helpful? Give feedback.
@schall1337 I'll open an issue to document and add an extra for transactional caches.
Today, as a workaround, what you can do for your tx cache is accessing directly from the RemoteCacheManager