in src/NMS.AMQP/NmsLocalTransactionContext.cs [197:238]
private async Task DoRollback(bool startNewTransaction)
{
Tracer.Debug($"Rollback: {this.transactionInfo.Id}");
var oldTransactionId = this.transactionInfo.Id;
var nextTx = startNewTransaction ? GetNextTransactionInfo() : null;
try
{
await this.connection.Rollback(this.transactionInfo, nextTx).Await();
OnTransactionRolledBack();
Reset();
this.transactionInfo = nextTx;
}
catch (Exception e)
{
Tracer.Info($"Rollback failed for transaction: {oldTransactionId}");
throw NMSExceptionSupport.Create(e);
}
finally
{
Reset();
try
{
// If the provider failed to start a new transaction there will not be
// a current provider transaction id present, so we attempt to create
// one to recover our state.
if (startNewTransaction && nextTx.ProviderTxId == null)
{
await Begin().Await();
}
}
catch (Exception e)
{
// TODO
// At this point the transacted session is now unrecoverable, we should
// probably close it.
Tracer.Info($"Failed to start new Transaction after failed rollback of: {this.transactionInfo} {e}");
}
}
}