/
vshmidt
/
masstransit
Обзор
Документация
Войти
/
vshmidt
/
masstransit
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/MassTransit/TransactionContextExtensions.cs
51 строка
2 KB
Chris Patterson
Integration of all external packages into MassTransit, split out into Abstractions, Middleware, and the core MassTransit assembly.
22 янв 2022, 18:24
22 янв 2022, 18:24
b5b4f50
Код
Авторство
О чём код?
namespace MassTransit { using System; using System.Transactions; public static class TransactionContextExtensions { /// <summary> /// Create a transaction scope using the transaction context (added by the TransactionFilter), /// to ensure that any transactions are carried between any threads. /// </summary> /// <param name="context"></param> /// <returns></returns> public static TransactionScope CreateTransactionScope(this PipeContext context) { var transactionContext = context.GetPayload<TransactionContext>(); return new TransactionScope(transactionContext.Transaction); } /// <summary> /// Create a transaction scope using the transaction context (added by the TransactionFilter), /// to ensure that any transactions are carried between any threads. /// </summary> /// <param name="context"></param> /// <param name="scopeTimeout">The timespan after which the scope times out and aborts the transaction</param> /// <returns></returns> public static TransactionScope CreateTransactionScope(this PipeContext context, TimeSpan scopeTimeout) { var transactionContext = context.GetPayload<TransactionContext>(); return new TransactionScope(transactionContext.Transaction, scopeTimeout); } /// <summary> /// Create a transaction scope using the transaction context (added by the TransactionFilter), /// to ensure that any transactions are carried between any threads. /// </summary> /// <param name="context"></param> /// <param name="scopeTimeout">The timespan after which the scope times out and aborts the transaction</param> /// <param name="asyncFlowOptions">Specifies whether transaction flow across thread continuations is enabled.</param> /// <returns></returns> public static TransactionScope CreateTransactionScope(this PipeContext context, TimeSpan scopeTimeout, TransactionScopeAsyncFlowOption asyncFlowOptions) { var transactionContext = context.GetPayload<TransactionContext>(); return new TransactionScope(transactionContext.Transaction, scopeTimeout, asyncFlowOptions); } } }