public async Task BeginAsync()
        {
            _transaction = await _clientOutboxStorage.BeginTransactionAsync().ConfigureAwait(false);

            _unitOfWorkContext.Set(_transaction);
            _unitOfWorkContext.Set <SynchronizedStorageSession>(_transaction);
        }
        public static ISqlStorageSession GetSqlSession(this IClientOutboxTransaction clientOutboxTransaction)
        {
            if (clientOutboxTransaction is ISqlStorageSession sqlSession)
            {
                return(sqlSession);
            }

            throw new Exception("Cannot access the SQL session");
        }
Exemple #3
0
        public Task StoreAsync(ClientOutboxMessageV2 clientOutboxMessage, IClientOutboxTransaction clientOutboxTransaction)
        {
            var sqlClientOutboxTransaction = (SqlClientOutboxTransaction)clientOutboxTransaction;

            using (var command = sqlClientOutboxTransaction.Connection.CreateCommand())
            {
                command.CommandText = StoreCommandText;
                command.CommandType = CommandType.Text;
                command.Transaction = sqlClientOutboxTransaction.Transaction;
                command.AddParameter("MessageId", clientOutboxMessage.MessageId);
                command.AddParameter("EndpointName", clientOutboxMessage.EndpointName);
                command.AddParameter("CreatedAt", _dateTimeService.UtcNow);
                command.AddParameter("Operations", JsonConvert.SerializeObject(clientOutboxMessage.TransportOperations, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.Auto
                }));

                return(command.ExecuteNonQueryAsync());
            }
        }