Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
204 views
in Technique[技术] by (71.8m points)

java - Ignite Factory<TransactionManager> is ignored

I am trying to set external transaction manager for Ignite Cache , however it appers that Factory is ignored and create is not called... The Factory Implementation is:

public class TransactionManagerFactory implements Factory<TransactionManager> {
private static final long serialVersionUID = 1L;
private transient IgniteCache igniteCache;

public TransactionManagerFactory(IgniteCache igniteCache) {
    this.igniteCache=igniteCache;
}

@Override
public TransactionManager create() {
    return this.igniteCache.getTransactionManager();
}
}

The Ignite transaction client configuration is set is following:

TransactionConfiguration txConfiguration=new TransactionConfiguration();
txConfiguration.setDeadlockTimeout(acquireTimeout);
txConfiguration.setDefaultTxIsolation(TransactionIsolation.READ_COMMITTED);
txConfiguration.setDefaultTxConcurrency(TransactionConcurrency.PESSIMISTIC);
TransactionManagerFactory txFactory=new TransactionManagerFactory(this);
txConfiguration.setTxManagerFactory(txFactory);           
this.clientConfig.setTransactionConfiguration(txConfiguration); 

The cache is getting created as:

CacheConfiguration<Object, Object> cacheCfg = new CacheConfiguration<Object, Object>(this.name);
cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
this.cache = this.instance.getOrCreateCache(cacheCfg);

However when in tests cache is created and connected to remote node and transaction is created by calling transactionManager.begin(); The instance.transactions().tx() is returning null , while transactionManager.getTransaction() return TransactionImpl{xid=Xid{formatId=1, globalTransactionId=8EA3F99497B60948C0E22AEBA1F54C460000000000000002,branchQualifier=8EA3F99497B60948C0E22AEBA1F54C460000000000000002}, status=ACTIVE}

And whenever the transaction is rolled back , the wrotten items persist in cache. Also TransactionManagerFactory.create is not executed at any time.

How can i correctly integrate external transaction manager with ignite cache?

BR Yulian Oifa

question from:https://stackoverflow.com/questions/66065287/ignite-factorytransactionmanager-is-ignored

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think you need to add ignite-jta module to your project in order for Ignite to do anything with transaction manager. Otherwise, NoOp implementation is used.

I'm not sure what you're trying to do with your transient IgniteCache logic. It will be null after deserialization and NPE will happen.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...