Example #1
0
        public override TransportReceiveInfrastructure ConfigureReceiveInfrastructure()
        {
            new CheckMachineNameForComplianceWithDtcLimitation().Check();

            MsmqScopeOptions scopeOptions;

            if (!settings.TryGet(out scopeOptions))
            {
                scopeOptions = new MsmqScopeOptions();
            }

            var msmqSettings = settings.Get <MsmqSettings>();

            return(new TransportReceiveInfrastructure(
                       () => new MessagePump(guarantee => SelectReceiveStrategy(guarantee, scopeOptions.TransactionOptions)),
                       () => new MsmqQueueCreator(msmqSettings.UseTransactionalQueues),
                       () =>
            {
                var bindings = settings.Get <QueueBindings>();

                foreach (var address in bindings.ReceivingAddresses)
                {
                    QueuePermissions.CheckQueue(address);
                }
                return Task.FromResult(StartupCheckResult.Success);
            }));
        }
        /// <summary>
        /// Allows to change the transaction isolation level and timeout for the `TransactionScope` used to receive messages.
        /// </summary>
        /// <remarks>
        /// If not specified the default transaction timeout of the machine will be used and the isolation level will be set to
        /// <see cref="IsolationLevel.ReadCommitted"/>.
        /// </remarks>
        /// <param name="timeout">Transaction timeout duration.</param>
        /// <param name="isolationLevel">Transaction isolation level.</param>
        public void ConfigureTransactionScope(TimeSpan?timeout = null, IsolationLevel?isolationLevel = null)
        {
            Guard.AgainstNegativeAndZero(nameof(timeout), timeout);

            if (isolationLevel == IsolationLevel.Snapshot)
            {
                throw new ArgumentException("Isolation level `Snapshot` is not supported by the transport. Consider not sharing the transaction between transport and persistence if persistence should use `IsolationLevel.Snapshot` by using `TransportTransactionMode.SendsAtomicWithReceive` or lower.", nameof(isolationLevel));
            }

            TransactionScopeOptions = new MsmqScopeOptions(timeout, isolationLevel);
        }
        public override TransportReceiveInfrastructure ConfigureReceiveInfrastructure()
        {
            new CheckMachineNameForComplianceWithDtcLimitation().Check();

            MsmqScopeOptions scopeOptions;

            if (!settings.TryGet(out scopeOptions))
            {
                scopeOptions = new MsmqScopeOptions();
            }

            var msmqSettings = settings.Get<MsmqSettings>();

            return new TransportReceiveInfrastructure(
                () => new MessagePump(guarantee => SelectReceiveStrategy(guarantee, scopeOptions.TransactionOptions)),
                () => new MsmqQueueCreator(msmqSettings.UseTransactionalQueues),
                () =>
                {
                    var bindings = settings.Get<QueueBindings>();

                    foreach (var address in bindings.ReceivingAddresses)
                    {
                        QueuePermissions.CheckQueue(address);
                    }
                    return Task.FromResult(StartupCheckResult.Success);
                });
        }