public async Task <ArraySegment <byte> > EnlistAsync( Transaction transaction, ServiceBusConnection serviceBusConnection) { if (transaction.IsolationLevel != IsolationLevel.Serializable) { throw new InvalidOperationException($"The only supported IsolationLevel is {nameof(IsolationLevel.Serializable)}"); } string transactionId = transaction.TransactionInformation.LocalIdentifier; bool fresh = false; AmqpTransactionEnlistment transactionEnlistment = this.enlistmentMap.GetOrAdd(transactionId, txId => { fresh = true; return(new AmqpTransactionEnlistment(transaction, this, serviceBusConnection)); }); if (fresh && !transaction.EnlistPromotableSinglePhase(transactionEnlistment)) { this.enlistmentMap.TryRemove(transactionId, out var _); throw new InvalidOperationException("Local transactions are not supported with other resource managers/DTC."); } transactionEnlistment = await transactionEnlistment.GetOrCreateAsync(serviceBusConnection.OperationTimeout).ConfigureAwait(false); return(transactionEnlistment.AmqpTransactionId); }
internal bool EnlistPromotableSinglePhase(AmqpTransactionEnlistment transactionEnlistment) { return(true); }