private void Enlist(Transaction transaction) { if (transaction == null) { // no enlistment as we are not in a TransactionScope return; } // try to enlist as a PSPE if (!transaction.EnlistPromotableSinglePhase(this)) { // our enlistmente fail so we need to enlist ourselves as durable. // we create a transaction directly instead of using BeginTransaction that GraphClient // doesn't store it in its stack of scopes. var localTransaction = new BoltNeo4jTransaction(((BoltGraphClient)client).Driver); var propagationToken = TransactionInterop.GetTransmitterPropagationToken(transaction); var transactionExecutionEnvironment = new BoltTransactionExecutionEnvironment(client.ExecutionConfiguration) { Session = this.transaction.Session, DriverTransaction = this.transaction.DriverTransaction, TransactionId = this.transactionId // TransactionId = localTransaction.Id, // TransactionBaseEndpoint = client.TransactionEndpoint }; ResourceManager.Enlist(transactionExecutionEnvironment, propagationToken); localTransaction.Cancel(); } enlistedInTransactions.Add(transaction); }
/// <inheritdoc /> public byte[] Promote() { // we have been promoted to MSTDC, so we have to clean the local resources if (transaction == null) { transaction = new BoltNeo4jTransaction(((BoltGraphClient)client).Driver); } transaction.Cancel(); transactionId = transaction.Id; var driverTx = transaction.DriverTransaction; var session = transaction.Session; transaction = null; // BUG: .NET 4.7.1 introduced a bug where the current transaction wouldn't get restored // after a call which crosses AppDomain boundaries. We have to restore it ourselves. // Ref https://github.com/Microsoft/dotnet-framework-early-access/issues/7 var tx = Transaction.Current; var res = ResourceManager.Promote(new BoltTransactionExecutionEnvironment(client.ExecutionConfiguration) { TransactionId = transactionId, Session = session, DriverTransaction = driverTx }); // Only restore if the bug exists to avoid any potentially side-effects // of setting the transaction if (Transaction.Current == null) { Transaction.Current = tx; } return(res); }
/// <inheritdoc /> public byte[] Promote() { // we have been promoted to MSTDC, so we have to clean the local resources if (transaction == null) { transaction = new BoltNeo4jTransaction(((BoltGraphClient)client).Driver); } transaction.Cancel(); transactionId = transaction.Id; var driverTx = transaction.DriverTransaction; var session = transaction.Session; transaction = null; return(ResourceManager.Promote(new BoltTransactionExecutionEnvironment(client.ExecutionConfiguration) { TransactionId = transactionId, Session = session, DriverTransaction = driverTx })); }