Interface XaFacade
-
- All Superinterfaces:
AutoCloseable,JdbcConnectionProvider,Serializable
@Internal public interface XaFacade extends JdbcConnectionProvider, Serializable, AutoCloseable
Facade to the XA operations relevant tosink.Typical workflow:
open()start(javax.transaction.xa.Xid)transactionJdbcConnectionProvider.getConnection(), write some dataendAndPrepare(javax.transaction.xa.Xid)(orfailAndRollback(javax.transaction.xa.Xid))commit(javax.transaction.xa.Xid, boolean)/rollback(javax.transaction.xa.Xid)AutoCloseable.close()
recover()can be used to get abandoned prepared transactions for cleanup.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classXaFacade.EmptyXaTransactionExceptionstatic classXaFacade.TransientXaExceptionIndicates a transient or unknown failure from the resource manager (seeXA_RBTRANSIENT,XAER_RMFAIL).
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcommit(Xid xid, boolean ignoreUnknown)Commit previously prepared transaction.voidendAndPrepare(Xid xid)End and then prepare the transaction.voidfailAndRollback(Xid xid)End transaction asfailed; in case of error, try to roll it back.static XaFacadefromXaDataSourceSupplier(java.util.function.Supplier<XADataSource> dataSourceSupplier, Integer timeoutSec, boolean transactionPerConnection)booleanisOpen()voidopen()Collection<Xid>recover()Note: this can block on some non-MVCC databases if there are ended not prepared transactions.voidrollback(Xid xid)Rollback previously prepared transaction.voidstart(Xid xid)Start a new transaction.-
Methods inherited from interface java.lang.AutoCloseable
close
-
Methods inherited from interface org.apache.flink.connector.jdbc.internal.connection.JdbcConnectionProvider
closeConnection, getConnection, getOrEstablishConnection, isConnectionValid, reestablishConnection
-
-
-
-
Method Detail
-
fromXaDataSourceSupplier
static XaFacade fromXaDataSourceSupplier(java.util.function.Supplier<XADataSource> dataSourceSupplier, Integer timeoutSec, boolean transactionPerConnection)
- Returns:
- a non-serializable instance.
-
isOpen
boolean isOpen()
-
endAndPrepare
void endAndPrepare(Xid xid) throws Exception
End and then prepare the transaction. Transaction can't be resumed afterwards.- Throws:
Exception
-
commit
void commit(Xid xid, boolean ignoreUnknown) throws XaFacade.TransientXaException
Commit previously prepared transaction.- Parameters:
ignoreUnknown- whether to ignoreXAER_NOTAerror.- Throws:
XaFacade.TransientXaException
-
rollback
void rollback(Xid xid) throws XaFacade.TransientXaException
Rollback previously prepared transaction.- Throws:
XaFacade.TransientXaException
-
failAndRollback
void failAndRollback(Xid xid) throws XaFacade.TransientXaException
End transaction asfailed; in case of error, try to roll it back.- Throws:
XaFacade.TransientXaException
-
recover
Collection<Xid> recover() throws XaFacade.TransientXaException
Note: this can block on some non-MVCC databases if there are ended not prepared transactions.- Throws:
XaFacade.TransientXaException
-
-