]
Galder Zamarreño updated ISPN-4983:
-----------------------------------
Status: Resolved (was: Pull Request Sent)
Fix Version/s: 7.1.0.Final
Resolution: Done
Public API for tracking completion of Infinispan work for a given
user transaction
----------------------------------------------------------------------------------
Key: ISPN-4983
URL:
https://issues.jboss.org/browse/ISPN-4983
Project: Infinispan
Issue Type: Feature Request
Reporter: Randall Hauch
Assignee: Pedro Ruivo
Labels: modeshape
Fix For: 7.1.0.Alpha1, 7.1.0.Final
When using Infinispan with user transactions, Infinispan will persist the changes to the
cache store using a synchronization on the user transaction. This means the persistence
operation begins when the user transaction has committed. However, components using
Infinispan will likely want to know when Infinispan's work has completed for a given
transaction.
In Infinispan 6, it was possible to do this by registering a transaction listener:
{code}
org.infinispan.Cache cache = ...
javax.transaction.Transaction activeTransaction = ...
org.infinispan.transaction.TransactionTable txnTable =
cache.getAdvancedCache().getComponentRegistry().getComponent(TransactionTable.class);
org.infinispan.transaction.xa.GlobalTransaction ispnTxID =
txnTable.getLocalTransaction(activeTransaction).getGlobalTransaction();
{code}
We'd then use the {{GlobalTransaction}} in our {{@Listener}}:
{code}
@Listener
class TxnListener {
@TransactionCompleted
public void transactionCompleted( TransactionCompletedEvent event ) {
if ( !event.isOriginLocal() ) return;
GlobalTransaction eventIspnTransaction = event.getGlobalTransaction();
if (eventIspnTransaction == null ||
ispnTxID.getId() != eventIspnTransaction.getId()) return;
if ( !event.isSuccessful() ) {
// do stuff
} else {
// do other stuff
}
}
{code}
However, this is no longer possible in Infinispan 7 since these classes were moved to an
"impl" package.
Can we please have a public API to be notified when Infinispan has complete its work for
a specific user transaction? It doesn't have to be like it was in 6, but ModeShape
needs something (see MODE-2353 for details).