I am trying to use custom transaction manager with ignite however it causes Failed to deserialize object with given class loader on startup. The Transaction Manager Factory is implemented as
public class TransactionManagerFactory implements Factory<TransactionManager> {
private static final long serialVersionUID = 1L;
private TransactionManager txMgr;
public TransactionManagerFactory(TransactionManager txMgr) {
this.txMgr=txMgr;
}
@Override
public TransactionManager create() {
return this.txMgr;
}
}
The Factory is attached to client config as following:
TransactionConfiguration txConfiguration=new TransactionConfiguration();
txConfiguration.setDeadlockTimeout(acquireTimeout);
txConfiguration.setDefaultTxIsolation(TransactionIsolation.READ_COMMITTED);
txConfiguration.setDefaultTxConcurrency(TransactionConcurrency.PESSIMISTIC);
txConfiguration.setTxManagerFactory(new TransactionManagerFactory(txMgr));
this.clientConfig.setTransactionConfiguration(txConfiguration);
The Error says the transaction Manager itself passed to Factory is not serializable: Caused by: java.io.NotSerializableException: org.infinispan.transaction.tm.EmbeddedBaseTransactionManager
However the Transaction Manager itself should not be serializable. How can we pass existing Transaction Manager to ignite client?
Your transaction manager factory holds on to a transaction manager instance instead of creating it in create()
method on a remote node. This is how it should work.
All non-transient fields of a serializable object must be serializable too.