protected override void Configure(FeatureConfigurationContext context, string connectionStringWithSchema)
        {
            //Until we refactor the whole address system
            Address.IgnoreMachineName();

            if (String.IsNullOrEmpty(connectionStringWithSchema))
            {
                throw new ArgumentException("Sql Transport connection string cannot be empty or null.");
            }

            foreach (var config in configs)
            {
                config.Configure(context, connectionStringWithSchema);
            }

            context.Container.ConfigureComponent(
                b => new SqlServerMessageSender(
                    b.Build <IConnectionStringProvider>(),
                    new ContextualConnectionStore(b.Build <PipelineExecutor>()),
                    new ContextualCallbackAddressStore(b.Build <PipelineExecutor>().CurrentContext),
                    b.Build <ConnectionFactory>()),
                DependencyLifecycle.InstancePerCall);

            if (!context.Settings.GetOrDefault <bool>("Endpoint.SendOnly"))
            {
                context.Container.ConfigureComponent <TransportNotifications>(DependencyLifecycle.SingleInstance);
                context.Container.ConfigureComponent <SqlServerQueueCreator>(DependencyLifecycle.InstancePerCall);

                var errorQueue = ErrorQueueSettings.GetConfiguredErrorQueue(context.Settings);
                context.Container.ConfigureComponent(b => new ReceiveStrategyFactory(new ContextualConnectionStore(b.Build <PipelineExecutor>()), b.Build <LocalConnectionParams>(), errorQueue, b.Build <ConnectionFactory>()), DependencyLifecycle.InstancePerCall);

                context.Container.ConfigureComponent <SqlServerPollingDequeueStrategy>(DependencyLifecycle.InstancePerCall);
                context.Container.ConfigureComponent(b => new SqlServerStorageContext(b.Build <PipelineExecutor>(), b.Build <LocalConnectionParams>()), DependencyLifecycle.InstancePerUnitOfWork);
            }
        }
Ejemplo n.º 2
0
        protected internal override void Setup(FeatureConfigurationContext context)
        {
            if (context.Settings.GetOrDefault <bool>("Endpoint.SendOnly"))
            {
                return;
            }

            var errorQueue = ErrorQueueSettings.GetConfiguredErrorQueue(context.Settings);

            context.Container.ConfigureComponent <FaultManager>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(fm => fm.ErrorQueue, errorQueue);
            context.Container.ConfigureComponent <FaultsQueueCreator>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(p => p.Enabled, true)
            .ConfigureProperty(t => t.ErrorQueue, errorQueue);
        }
        /// <summary>
        /// Initializes a new instance of <see cref="ConfigureTransport"/>.
        /// </summary>
        protected override void Configure(FeatureConfigurationContext context, string connectionString)
        {
            new CheckMachineNameForComplianceWithDtcLimitation()
            .Check();

            context.Container.ConfigureComponent <CorrelationIdMutatorForBackwardsCompatibilityWithV3>(DependencyLifecycle.InstancePerCall);
            context.Container.ConfigureComponent <MsmqUnitOfWork>(DependencyLifecycle.SingleInstance);

            if (!context.Settings.GetOrDefault <bool>("Endpoint.SendOnly"))
            {
                context.Container.ConfigureComponent <MsmqDequeueStrategy>(DependencyLifecycle.InstancePerCall)
                .ConfigureProperty(p => p.ErrorQueue, ErrorQueueSettings.GetConfiguredErrorQueue(context.Settings));
            }

            var cfg = context.Settings.GetConfigSection <MsmqMessageQueueConfig>();

            var settings = new MsmqSettings();

            if (cfg != null)
            {
                settings.UseJournalQueue    = cfg.UseJournalQueue;
                settings.UseDeadLetterQueue = cfg.UseDeadLetterQueue;

                Logger.Warn(Message);
            }
            else
            {
                if (connectionString != null)
                {
                    settings = new MsmqConnectionStringBuilder(connectionString).RetrieveSettings();
                }
            }

            context.Container.ConfigureComponent <MsmqMessageSender>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(t => t.Settings, settings)
            .ConfigureProperty(t => t.SuppressDistributedTransactions, context.Settings.Get <bool>("Transactions.SuppressDistributedTransactions"));

            context.Container.ConfigureComponent <MsmqQueueCreator>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(t => t.Settings, settings);
        }