/// <summary>
        /// Initializes the transport infrastructure for msmq.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="connectionString">The connection string.</param>
        /// <returns>the transport infrastructure for msmq.</returns>
        public override TransportInfrastructure Initialize(SettingsHolder settings, string connectionString)
        {
            Guard.AgainstNull(nameof(settings), settings);

            if (!settings.GetOrDefault <bool>("Endpoint.SendOnly") && !settings.TryGetExplicitlyConfiguredErrorQueueAddress(out _))
            {
                throw new Exception("Faults forwarding requires an error queue to be specified using 'EndpointConfiguration.SendFailedMessagesTo()'");
            }

            if (connectionString != null)
            {
                var error = @"Passing in MSMQ settings such as DeadLetterQueue, Journaling etc via a connection string is no longer supported.  Use code level API. For example:
To turn off dead letter queuing, use: 
var transport = endpointConfiguration.UseTransport<MsmqTransport>();
transport.DisableDeadLetterQueueing();

To stop caching connections, use: 
var transport = endpointConfiguration.UseTransport<MsmqTransport>();
transport.DisableConnectionCachingForSends();

To use non-transactional queues, use:
var transport = endpointConfiguration.UseTransport<MsmqTransport>();
transport.UseNonTransactionalQueues();

To enable message journaling, use:
var transport = endpointConfiguration.UseTransport<MsmqTransport>();
transport.EnableJournaling();

To override the value of TTRQ, use:
var transport = endpointConfiguration.UseTransport<MsmqTransport>();
transport.TimeToReachQueue(timespanValue);";

                throw new Exception(error);
            }

            var msmqSettings = new MsmqSettings(settings);

            var isTransactional = IsTransactional(settings);
            var outBoxRunning   = settings.IsFeatureActive(typeof(Features.Outbox));

            settings.TryGetAuditMessageExpiration(out var auditMessageExpiration);

            return(new MsmqTransportInfrastructure(settings, msmqSettings, settings.Get <QueueBindings>(), isTransactional, outBoxRunning, auditMessageExpiration));
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes the transport infrastructure for msmq.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="connectionString">The connection string.</param>
        /// <returns>the transport infrastructure for msmq.</returns>
        public override TransportInfrastructure Initialize(SettingsHolder settings, string connectionString)
        {
            Guard.AgainstNull(nameof(settings), settings);
            string errorQueue;

            if (!settings.GetOrDefault <bool>("Endpoint.SendOnly") && !settings.TryGetExplicitlyConfiguredErrorQueueAddress(out errorQueue))
            {
                throw new Exception("Faults forwarding requires an error queue to be specified using 'EndpointConfiguration.SendFailedMessagesTo()'");
            }

            settings.EnableFeature(typeof(InstanceMappingFileFeature));

            var msmqSettings = connectionString != null ? new MsmqConnectionStringBuilder(connectionString)
                               .RetrieveSettings() : new MsmqSettings();

            msmqSettings.UseDeadLetterQueueForMessagesWithTimeToBeReceived = settings.GetOrDefault <bool>(UseDeadLetterQueueForMessagesWithTimeToBeReceived);

            settings.Set <MsmqSettings>(msmqSettings);

            return(new MsmqTransportInfrastructure(settings));
        }