コード例 #1
0
        public static Configure NLog(this Configure config, params object[] targetsForNServiceBusToLogTo)
        {
            if (targetsForNServiceBusToLogTo == null)
            {
                throw new ArgumentNullException("targetsForNServiceBusToLogTo");
            }
            if (targetsForNServiceBusToLogTo.Length == 0)
            {
                throw new ArgumentException("Must not be empty.", "targetsForNServiceBusToLogTo");
            }
            if (targetsForNServiceBusToLogTo.Any(x => x == null))
            {
                throw new ArgumentNullException("targetsForNServiceBusToLogTo", "Must not contain null values.");
            }
            string threshold = null;

            var cfg = Configure.GetConfigSection <Config.Logging>();

            if (cfg != null)
            {
                threshold = cfg.Threshold;
            }

            NLogConfigurator.Configure(targetsForNServiceBusToLogTo, threshold);

            return(config);
        }
コード例 #2
0
        public static Configure AzureMessageQueue(this Configure config)
        {
            CloudQueueClient queueClient;

            var configSection = Configure.GetConfigSection <AzureQueueConfig>();

            if (configSection != null)
            {
                queueClient = CloudStorageAccount.Parse(configSection.ConnectionString)
                              .CreateCloudQueueClient();
            }
            else
            {
                queueClient = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudQueueClient();
            }

            config.Configurer.RegisterSingleton <CloudQueueClient>(queueClient);

            config.Configurer.ConfigureComponent <AzureMessageQueue>(DependencyLifecycle.SingleInstance);

            if (configSection != null)
            {
                Configure.Instance.Configurer.ConfigureProperty <AzureMessageQueue>(t => t.PurgeOnStartup, configSection.PurgeOnStartup);
                Configure.Instance.Configurer.ConfigureProperty <AzureMessageQueue>(t => t.MaximumWaitTimeWhenIdle, configSection.MaximumWaitTimeWhenIdle);
                Configure.Instance.Configurer.ConfigureProperty <AzureMessageQueue>(t => t.MessageInvisibleTime, configSection.MessageInvisibleTime);
                Configure.Instance.Configurer.ConfigureProperty <AzureMessageQueue>(t => t.PeekInterval, configSection.PeekInterval);
            }

            return(config);
        }
コード例 #3
0
        /// <summary>
        /// Configures NHibernate Timeout Persister.
        /// </summary>
        /// <remarks>
        /// Reads configuration settings from <a href="http://msdn.microsoft.com/en-us/library/ms228154.aspx">&lt;appSettings&gt; config section</a> and <a href="http://msdn.microsoft.com/en-us/library/bf7sd233">&lt;connectionStrings&gt; config section</a>.
        /// </remarks>
        /// <example>
        /// An example that shows the minimum configuration:
        /// <code lang="XML" escaped="true">
        ///  <appSettings>
        ///    <!-- other optional settings examples -->
        ///    <add key="NServiceBus/Persistence/NHibernate/connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
        ///    <add key="NServiceBus/Persistence/NHibernate/connection.driver_class" value="NHibernate.Driver.Sql2008ClientDriver"/>
        ///    <!-- For more setting see http://www.nhforge.org/doc/nh/en/#configuration-hibernatejdbc and http://www.nhforge.org/doc/nh/en/#configuration-optional -->
        ///  </appSettings>
        ///
        ///  <connectionStrings>
        ///    <!-- Default connection string for all persisters -->
        ///    <add name="NServiceBus/Persistence/NHibernate" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True" />
        ///
        ///    <!-- Optional overrides per persister -->
        ///    <add name="NServiceBus/Persistence/NHibernate/Timeout" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=timeout;Integrated Security=True" />
        ///  </connectionStrings>
        /// </code>
        /// </example>
        /// <param name="config">The configuration object.</param>
        /// <returns>The configuration object.</returns>
        public static Configure UseNHibernateTimeoutPersister(this Configure config)
        {
            var configSection = Configure.GetConfigSection <TimeoutPersisterConfig>();

            if (configSection != null)
            {
                if (configSection.NHibernateProperties.Count == 0)
                {
                    throw new InvalidOperationException(
                              "No NHibernate properties found. Please specify NHibernateProperties in your TimeoutPersisterConfig section");
                }

                foreach (var property in configSection.NHibernateProperties.ToProperties())
                {
                    ConfigureNHibernate.TimeoutPersisterProperties[property.Key] = property.Value;
                }
            }

            ConfigureNHibernate.ConfigureSqlLiteIfRunningInDebugModeAndNoConfigPropertiesSet(ConfigureNHibernate.TimeoutPersisterProperties);

            var properties = ConfigureNHibernate.TimeoutPersisterProperties;

            return(config.UseNHibernateTimeoutPersisterInternal(ConfigureNHibernate.CreateConfigurationWith(properties),
                                                                configSection == null || configSection.UpdateSchema));
        }
コード例 #4
0
        /// <summary>
        /// Use 256 bit AES encryption based on the Rijndael cipher.
        /// </summary>
        public static Configure RijndaelEncryptionService(this Configure config)
        {
            var section = Configure.GetConfigSection <RijndaelEncryptionServiceConfig>();

            if (section == null)
            {
                Logger.Warn("Could not find configuration section for Rijndael Encryption Service.");
            }

            var encryptionService = new EncryptionService();

            if (section != null)
            {
                if (string.IsNullOrWhiteSpace(section.Key))
                {
                    throw new Exception("The RijndaelEncryptionServiceConfig has an empty 'Key' attribute.");
                }
                var expiredKeys = ExtractExpiredKeysFromConfigSection(section);

                encryptionService.Key         = Encoding.ASCII.GetBytes(section.Key);
                encryptionService.ExpiredKeys = expiredKeys.Select(x => Encoding.ASCII.GetBytes(x)).ToList();
            }

            encryptionService.VerifyKeysAreNotTooSimilar();

            config.Configurer.RegisterSingleton <IEncryptionService>(encryptionService);

            return(config);
        }
コード例 #5
0
        public const int DefaultBlockSize           = 4 * 1024 * 1024; // 4MB

        public static Configure AzureDataBus(this Configure config)
        {
            var container = Defaultcontainer;

            CloudBlobClient cloudBlobClient;

            var configSection = Configure.GetConfigSection <AzureDataBusConfig>();

            if (configSection != null)
            {
                cloudBlobClient = CloudStorageAccount.Parse(configSection.ConnectionString).CreateCloudBlobClient();

                container = configSection.Container;
            }
            else
            {
                cloudBlobClient = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudBlobClient();
            }

            var dataBus = new BlobStorageDataBus(cloudBlobClient.GetContainerReference(container));

            if (configSection != null)
            {
                dataBus.BasePath          = configSection.BasePath;
                dataBus.MaxRetries        = configSection.MaxRetries;
                dataBus.NumberOfIOThreads = configSection.NumberOfIOThreads;
                dataBus.BlockSize         = configSection.BlockSize;
            }

            config.Configurer.RegisterSingleton <IDataBus>(dataBus);

            return(config);
        }
コード例 #6
0
        /// <summary>
        /// Use MSMQ for your queuing infrastructure.
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Configure MsmqTransport(this Configure config)
        {
            Selected = true;

            config.Configurer.ConfigureComponent <MsmqMessageReceiver>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(p => p.PurgeOnStartup, ConfigurePurging.PurgeRequested);

            config.Configurer.ConfigureComponent <MsmqMessageSender>(DependencyLifecycle.SingleInstance);

            var cfg = Configure.GetConfigSection <MsmqMessageQueueConfig>();

            var useJournalQueue    = false;
            var useDeadLetterQueue = true;

            if (cfg != null)
            {
                useJournalQueue    = cfg.UseJournalQueue;
                useDeadLetterQueue = cfg.UseDeadLetterQueue;
            }
            config.Configurer.ConfigureProperty <MsmqMessageSender>(t => t.UseDeadLetterQueue, useDeadLetterQueue);
            config.Configurer.ConfigureProperty <MsmqMessageSender>(t => t.UseJournalQueue, useJournalQueue);

            EndpointInputQueueInstaller.Enabled = true;
            MsmqInfrastructureInstaller.Enabled = true;

            return(config);
        }
コード例 #7
0
        /// <summary>
        /// Forward messages that have repeatedly failed to another endpoint.
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Configure MessageForwardingInCaseOfFault(this Configure config)
        {
            var section = Configure.GetConfigSection <MessageForwardingInCaseOfFaultConfig>();

            if (section == null)
            {
                Logger.Warn("Could not find configuration section 'MessageForwardingInCaseOfFaultConfig'. Going to try to find the error queue defined in 'MsmqTransportConfig'.");

                var msmq = Configure.GetConfigSection <MsmqTransportConfig>();
                if (msmq == null)
                {
                    throw new ConfigurationErrorsException("Could not find backup configuration section 'MsmqTransportConfig' in order to locate the error queue.");
                }


                ErrorQueue = msmq.ErrorQueue;
            }
            else
            {
                ErrorQueue = section.ErrorQueue;
            }

            if (string.IsNullOrEmpty(ErrorQueue))
            {
                throw new ConfigurationErrorsException("Faults forwarding requires a error queue to be specified. Please add a 'MessageForwardingInCaseOfFaultConfig' section to your app.config");
            }

            config.Configurer.ConfigureComponent <FaultManager>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(fm => fm.ErrorQueue, ErrorQueue);

            return(config);
        }
コード例 #8
0
        /// <summary>
        /// Use Log4Net for logging passing in a pre-configured appender.
        /// Will call 'ActivateOptions()' on the appender for you.
        /// If you don't specify a threshold, will default to Level.Debug.
        /// If you don't specify layout, uses this as a default: %d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m%n
        /// </summary>
        public static Configure Log4Net(this Configure config, object appenderSkeleton)
        {
            var threshold = GetThresholdFromConfigSection(Configure.GetConfigSection <Config.Logging>());

            Logging.Loggers.Log4NetAdapter.Log4NetConfigurator.Configure(appenderSkeleton, threshold);

            return(config);
        }
コード例 #9
0
        /// <summary>
        /// Forward messages that have repeatedly failed to another endpoint.
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Configure MessageForwardingInCaseOfFault(this Configure config)
        {
            if (ErrorQueue != null)
            {
                return(config);
            }
            if (SettingsHolder.Get <bool>("Endpoint.SendOnly"))
            {
                return(config);
            }

            ErrorQueue = Address.Undefined;

            var section = Configure.GetConfigSection <MessageForwardingInCaseOfFaultConfig>();

            if (section != null)
            {
                if (string.IsNullOrWhiteSpace(section.ErrorQueue))
                {
                    throw new ConfigurationErrorsException(
                              "'MessageForwardingInCaseOfFaultConfig' configuration section is found but 'ErrorQueue' value is missing." +
                              "\n The following is an example for adding such a value to your app config: " +
                              "\n <MessageForwardingInCaseOfFaultConfig ErrorQueue=\"error\"/> \n");
                }

                Logger.Debug("Error queue retrieved from <MessageForwardingInCaseOfFaultConfig> element in config file.");

                ErrorQueue = Address.Parse(section.ErrorQueue);

                config.Configurer.ConfigureComponent <FaultManager>(DependencyLifecycle.InstancePerCall)
                .ConfigureProperty(fm => fm.ErrorQueue, ErrorQueue);

                return(config);
            }


            var errorQueue = RegistryReader <string> .Read("ErrorQueue");

            if (!string.IsNullOrWhiteSpace(errorQueue))
            {
                Logger.Debug("Error queue retrieved from registry settings.");
                ErrorQueue = Address.Parse(errorQueue);

                config.Configurer.ConfigureComponent <FaultManager>(DependencyLifecycle.InstancePerCall)
                .ConfigureProperty(fm => fm.ErrorQueue, ErrorQueue);
            }

            if (ErrorQueue == Address.Undefined)
            {
                throw new ConfigurationErrorsException("Faults forwarding requires an error queue to be specified. Please add a 'MessageForwardingInCaseOfFaultConfig' section to your app.config" +
                                                       "\n or configure a global one using the powershell command: Set-NServiceBusLocalMachineSettings -ErrorQueue {address of error queue}");
            }

            return(config);
        }
コード例 #10
0
        public static string GetMasterNode(this Configure config)
        {
            var section = Configure.GetConfigSection <MasterNodeConfig>();

            if (section != null)
            {
                return(section.Node);
            }

            return(null);
        }
コード例 #11
0
        /// <summary>
        /// Return Timeout Manager Address. Uses "TimeoutManagerAddress" parameter form config file if defined, if not, uses "EndpointName.Timeouts".
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Address GetTimeoutManagerAddress(this Configure config)
        {
            var unicastConfig = Configure.GetConfigSection <UnicastBusConfig>();

            if (unicastConfig != null && !string.IsNullOrWhiteSpace(unicastConfig.TimeoutManagerAddress))
            {
                return(Address.Parse(unicastConfig.TimeoutManagerAddress));
            }

            return(config.GetMasterNodeAddress().SubScope("Timeouts"));
        }
コード例 #12
0
        /// <summary>
        /// Return Timeout Manager Address. Uses "TimeoutManagerAddress" parameter form config file if defined, if not, uses "EndpointName.Timeouts".
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Address GetTimeoutManagerAddress(this Configure config)
        {
            var unicastConfig = Configure.GetConfigSection <UnicastBusConfig>();

            if ((unicastConfig != null) && (!String.IsNullOrWhiteSpace(unicastConfig.TimeoutManagerAddress)))
            {
                return(Address.Parse(unicastConfig.TimeoutManagerAddress));
            }

            return(Address.Parse(Configure.EndpointName).SubScope("Timeouts"));
        }
コード例 #13
0
        /// <summary>
        /// Configures NHibernate Azure Subscription Storage , Settings etc are read from custom config section
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Configure AzureSubscriptionStorage(this Configure config)
        {
            var configSection = Configure.GetConfigSection <AzureSubscriptionStorageConfig>();

            if (configSection == null)
            {
                return(config);
            }

            return(config.AzureSubcriptionStorage(configSection.ConnectionString, configSection.CreateSchema, configSection.TableName));
        }
コード例 #14
0
        /// <summary>
        /// Configures NHibernate Azure Subscription Storage , Settings etc are read from custom config section
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Configure AzureSubcriptionStorage(this Configure config)
        {
            var configSection = Configure.GetConfigSection <AzureSubscriptionStorageConfig>();

            if (configSection == null)
            {
                throw new InvalidOperationException("No configuration section for NHibernate Azure Subscription Storage found. Please add a NHibernateAzureSubscriptionStorageConfig section to you configuration file");
            }

            return(AzureSubcriptionStorage(config, configSection.ConnectionString, configSection.CreateSchema));
        }
コード例 #15
0
ファイル: Configurer.cs プロジェクト: ravikp/NServiceBus
        private static string GetInputQueue(MsmqTransportConfig msmqTransportConfig)
        {
            var unicastBusConfig = Configure.GetConfigSection <UnicastBusConfig>();

            var inputQueue = unicastBusConfig.LocalAddress;

            if (inputQueue == null)
            {
                inputQueue = msmqTransportConfig.InputQueue;
            }
            return(inputQueue);
        }
コード例 #16
0
        public static Configure AzureMessageQueue(this Configure config)
        {
            CloudQueueClient queueClient;

            var configSection = Configure.GetConfigSection <AzureQueueConfig>();

            Address.InitializeAddressMode(AddressMode.Remote);

            if (configSection != null)
            {
                queueClient = CloudStorageAccount.Parse(configSection.ConnectionString).CreateCloudQueueClient();
                Address.OverrideDefaultMachine(configSection.ConnectionString);

                if (configSection.QueuePerInstance)
                {
                    Configure.Instance.CustomConfigurationSource(new IndividualQueueConfigurationSource(Configure.ConfigurationSource));
                }
            }
            else
            {
                queueClient = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudQueueClient();
                Address.OverrideDefaultMachine(NServiceBus.Unicast.Queuing.Azure.AzureMessageQueue.DefaultConnectionString);
            }

            config.Configurer.RegisterSingleton <CloudQueueClient>(queueClient);

            config.Configurer.ConfigureComponent <AzureMessageQueue>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(p => p.PurgeOnStartup, ConfigurePurging.PurgeRequested);

            if (configSection != null)
            {
                Configure.Instance.Configurer.ConfigureProperty <AzureMessageQueue>(t => t.PurgeOnStartup, configSection.PurgeOnStartup);
                Configure.Instance.Configurer.ConfigureProperty <AzureMessageQueue>(t => t.MaximumWaitTimeWhenIdle, configSection.MaximumWaitTimeWhenIdle);
                Configure.Instance.Configurer.ConfigureProperty <AzureMessageQueue>(t => t.MessageInvisibleTime, configSection.MessageInvisibleTime);
                Configure.Instance.Configurer.ConfigureProperty <AzureMessageQueue>(t => t.PeekInterval, configSection.PeekInterval);
            }

            if (configSection != null && !string.IsNullOrEmpty(configSection.QueueName))
            {
                Configure.Instance.DefineEndpointName(configSection.QueueName);
            }
            else if (RoleEnvironment.IsAvailable)
            {
                Configure.Instance.DefineEndpointName(RoleEnvironment.CurrentRoleInstance.Role.Name);
            }
            Address.InitializeLocalAddress(Configure.EndpointName);


            return(config);
        }
コード例 #17
0
        /// <summary>
        /// Use Log4Net for logging passing in a pre-configured appender.
        /// Will call 'ActivateOptions()' on the appender for you.
        /// If you don't specify a threshold, will default to Level.Debug.
        /// If you don't specify layout, uses this as a default: %d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m%n
        /// </summary>
        public static Configure Log4Net(this Configure config, object appenderSkeleton)
        {
            string threshold = null;

            var cfg = Configure.GetConfigSection <Config.Logging>();

            if (cfg != null)
            {
                threshold = cfg.Threshold;
            }

            Logging.Loggers.Log4NetAdapter.Log4NetConfigurator.Configure(appenderSkeleton, threshold);

            return(config);
        }
コード例 #18
0
        /// <summary>
        /// Use the NHibernate backed saga persister implementation.
        /// Be aware that this implementation deletes sagas that complete so as not to have the database fill up.
        /// SagaData classes are automatically mapped using Fluent NHibernate Conventions.
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Configure AzureSagaPersister(this Configure config)
        {
            string connectionstring = string.Empty;
            bool   updateSchema     = false;

            var configSection = Configure.GetConfigSection <AzureSagaPersisterConfig>();

            if (configSection != null)
            {
                connectionstring = configSection.ConnectionString;
                updateSchema     = configSection.CreateSchema;
            }

            return(AzureSagaPersister(config, connectionstring, updateSchema));
        }
コード例 #19
0
        /// <summary>
        /// Use the NHibernate backed saga persister implementation.
        /// Be aware that this implementation deletes sagas that complete so as not to have the database fill up.
        /// SagaData classes are automatically mapped using Fluent NHibernate Conventions.
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Configure NHibernateSagaPersister(this Configure config)
        {
            IDictionary <string, string> nhibernateProperties = null;
            bool updateSchema = false;

            var configSection = Configure.GetConfigSection <NHibernateSagaPersisterConfig>();

            if (configSection != null)
            {
                nhibernateProperties = configSection.NHibernateProperties.ToProperties();
                updateSchema         = configSection.UpdateSchema;
            }

            return(NHibernateSagaPersister(config, nhibernateProperties, updateSchema));
        }
コード例 #20
0
        public static Configure AzureServiceBusMessageQueue(this Configure config)
        {
            var configSection = Configure.GetConfigSection <AzureServiceBusQueueConfig>();

            if (configSection == null)
            {
                throw new ConfigurationErrorsException("No AzureServiceBusQueueConfig configuration section found");
            }

            Address.InitializeAddressMode(AddressMode.Remote);

            var credentials     = TokenProvider.CreateSharedSecretTokenProvider(configSection.IssuerName, configSection.IssuerKey);
            var serviceUri      = ServiceBusEnvironment.CreateServiceUri("sb", configSection.ServiceNamespace, string.Empty);
            var namespaceClient = new NamespaceManager(serviceUri, credentials);
            var factory         = MessagingFactory.Create(serviceUri, credentials);

            Address.OverrideDefaultMachine(serviceUri.ToString());

            config.Configurer.RegisterSingleton <NamespaceManager>(namespaceClient);
            config.Configurer.RegisterSingleton <MessagingFactory>(factory);

            config.Configurer.ConfigureComponent <AzureServiceBusMessageQueue>(DependencyLifecycle.SingleInstance);

            Configure.Instance.Configurer.ConfigureProperty <AzureServiceBusMessageQueue>(t => t.LockDuration, TimeSpan.FromMilliseconds(configSection.LockDuration));
            Configure.Instance.Configurer.ConfigureProperty <AzureServiceBusMessageQueue>(t => t.MaxSizeInMegabytes, configSection.MaxSizeInMegabytes);
            Configure.Instance.Configurer.ConfigureProperty <AzureServiceBusMessageQueue>(t => t.RequiresDuplicateDetection, configSection.RequiresDuplicateDetection);
            Configure.Instance.Configurer.ConfigureProperty <AzureServiceBusMessageQueue>(t => t.RequiresSession, configSection.RequiresSession);
            Configure.Instance.Configurer.ConfigureProperty <AzureServiceBusMessageQueue>(t => t.DefaultMessageTimeToLive, TimeSpan.FromMilliseconds(configSection.DefaultMessageTimeToLive));
            Configure.Instance.Configurer.ConfigureProperty <AzureServiceBusMessageQueue>(t => t.EnableDeadLetteringOnMessageExpiration, configSection.EnableDeadLetteringOnMessageExpiration);
            Configure.Instance.Configurer.ConfigureProperty <AzureServiceBusMessageQueue>(t => t.DuplicateDetectionHistoryTimeWindow, TimeSpan.FromMilliseconds(configSection.DuplicateDetectionHistoryTimeWindow));
            Configure.Instance.Configurer.ConfigureProperty <AzureServiceBusMessageQueue>(t => t.MaxDeliveryCount, configSection.MaxDeliveryCount);
            Configure.Instance.Configurer.ConfigureProperty <AzureServiceBusMessageQueue>(t => t.EnableBatchedOperations, configSection.EnableBatchedOperations);

            if (!string.IsNullOrEmpty(configSection.QueueName))
            {
                Configure.Instance.DefineEndpointName(configSection.QueuePerInstance
                                                          ? QueueIndividualizer.Individualize(configSection.QueueName)
                                                          : configSection.QueueName);
            }
            else if (RoleEnvironment.IsAvailable)
            {
                Configure.Instance.DefineEndpointName(RoleEnvironment.CurrentRoleInstance.Role.Name);
            }
            Address.InitializeLocalAddress(Configure.EndpointName);


            return(config);
        }
コード例 #21
0
        /// <summary>
        /// Use the in azure timeout persister implementation.
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Configure UseAzureTimeoutPersister(this Configure config)
        {
            var configSection = Configure.GetConfigSection <AzureTimeoutPersisterConfig>() ?? new AzureTimeoutPersisterConfig();

            config.Configurer.ConfigureComponent <TimeoutPersisterReceiver>(DependencyLifecycle.SingleInstance);
            config.Configurer.ConfigureComponent <DefaultTimeoutManager>(DependencyLifecycle.SingleInstance);

            ServiceContext.TimeoutDataTableName        = configSection.TimeoutDataTableName;
            ServiceContext.TimeoutManagerDataTableName = configSection.TimeoutManagerDataTableName;

            config.Configurer.ConfigureComponent <TimeoutPersister>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(tp => tp.ConnectionString, configSection.ConnectionString)
            .ConfigureProperty(tp => tp.CatchUpInterval, configSection.CatchUpInterval)
            .ConfigureProperty(tp => tp.PartitionKeyScope, configSection.PartitionKeyScope);
            return(config);
        }
コード例 #22
0
        /// <summary>
        /// Stores subscription data using MSMQ.
        /// If multiple machines need to share the same list of subscribers,
        /// you should not choose this option - prefer the DbSubscriptionStorage
        /// in that case.
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Configure MsmqSubscriptionStorage(this Configure config)
        {
            var cfg = Configure.GetConfigSection <MsmqSubscriptionStorageConfig>();

            if (cfg == null)
            {
                Logger.Warn("Could not find configuration section for Msmq Subscription Storage.");
            }

            Queue = (cfg != null ? cfg.Queue : "NServiceBus_Subscriptions");

            var storageConfig = config.Configurer.ConfigureComponent <MsmqSubscriptionStorage>(DependencyLifecycle.SingleInstance);

            storageConfig.ConfigureProperty(s => s.Queue, Queue);

            return(config);
        }
コード例 #23
0
        public static Configure FtpTransport(this Configure config)
        {
            var ftpQueue = config.Configurer.ConfigureComponent <FtpMessageQueue>(DependencyLifecycle.SingleInstance);
            var cfg      = Configure.GetConfigSection <FtpQueueConfig>();

            if (cfg != null)
            {
                ftpQueue.ConfigureProperty(t => t.ReceiveDirectory, cfg.ReceiveDirectory);

                if (!String.IsNullOrEmpty(cfg.UserName))
                {
                    ftpQueue.ConfigureProperty(t => t.UserName, cfg.UserName);
                    ftpQueue.ConfigureProperty(t => t.Password, cfg.Password);
                }
            }

            return(config);
        }
コード例 #24
0
        /// <summary>
        /// Use 256 bit AES encryption based on the Rijndael cipher.
        /// </summary>
        public static Configure RijndaelEncryptionService(this Configure config)
        {
            var section = Configure.GetConfigSection <RijndaelEncryptionServiceConfig>();

            if (section == null)
            {
                Logger.Warn("Could not find configuration section for Rijndael Encryption Service.");
            }

            var encryptConfig = config.Configurer.ConfigureComponent <EncryptionService>(DependencyLifecycle.SingleInstance);

            if (section != null)
            {
                encryptConfig.ConfigureProperty(s => s.Key, Encoding.ASCII.GetBytes(section.Key));
            }

            return(config);
        }
コード例 #25
0
        /// <summary>
        /// Use MSMQ for your queuing infrastructure.
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Configure MsmqTransport(this Configure config)
        {
            Selected = true;

            config.Configurer.ConfigureComponent <MsmqMessageReceiver>(DependencyLifecycle.SingleInstance);
            config.Configurer.ConfigureComponent <MsmqMessageSender>(DependencyLifecycle.SingleInstance);


            var cfg = Configure.GetConfigSection <MsmqMessageQueueConfig>();

            if (cfg != null)
            {
                config.Configurer.ConfigureProperty <MsmqMessageSender>(t => t.UseDeadLetterQueue, cfg.UseJournalQueue);
                config.Configurer.ConfigureProperty <MsmqMessageSender>(t => t.UseJournalQueue, cfg.UseJournalQueue);
            }

            return(config);
        }
コード例 #26
0
        /// <summary>
        /// Configures DB Subscription Storage , DB Settings etc are read from custom config section (DBSubscriptionStoreage)
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Configure DBSubcriptionStorage(this Configure config)
        {
            var configSection = Configure.GetConfigSection <DBSubscriptionStorageConfig>();

            if (configSection == null)
            {
                throw new InvalidOperationException("No configuration section for DB Subscription Storage found. Pleas add a DBSubscriptionStorageConfig section to you configuration file");
            }


            if (configSection.NHibernateProperties.Count == 0)
            {
                throw new InvalidOperationException("No NHibernate properties found. Please specify NHibernateProperties in your DBSubscriptionStorageConfig section");
            }

            return(DBSubcriptionStorage(config,
                                        new Configuration().AddProperties(configSection.NHibernateProperties.ToProperties()),
                                        configSection.UpdateSchema));
        }
コード例 #27
0
        /// <summary>
        /// Configures NHibernate Timeout Persister.
        /// Database settings are read from custom config section <see cref="TimeoutPersisterConfig"/>.
        /// </summary>
        /// <param name="config">The configuration object.</param>
        /// <returns>The configuration object.</returns>
        public static Configure UseNHibernateTimeoutPersister(this Configure config)
        {
            var configSection = Configure.GetConfigSection <TimeoutPersisterConfig>();

            if (configSection == null)
            {
                throw new InvalidOperationException("No configuration section for DB Timeout Storage found. Please add a TimeoutPersisterConfig section to you configuration file");
            }


            if (configSection.NHibernateProperties.Count == 0)
            {
                throw new InvalidOperationException("No NHibernate properties found. Please specify NHibernateProperties in your TimeoutPersisterConfig section");
            }

            return(UseNHibernateTimeoutPersister(config,
                                                 new Configuration().AddProperties(configSection.NHibernateProperties.ToProperties()),
                                                 configSection.UpdateSchema));
        }
コード例 #28
0
        /// <summary>
        /// Use Log4Net for logging passing in a pre-configured appender.
        /// Will call 'ActivateOptions()' on the appender for you.
        /// If you don't specify a threshold, will default to Level.Debug.
        /// If you don't specify layout, uses this as a default: %d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m%n
        /// </summary>
        public static Configure Log4Net(this Configure config, object appenderSkeleton)
        {
            var appender = appenderSkeleton as AppenderSkeleton;

            if (appender == null)
            {
                throw new ArgumentException("The object provided must inherit from log4net.Appender.AppenderSkeleton.");
            }

            Log4Net();

            if (appender.Layout == null)
            {
                appender.Layout = new log4net.Layout.PatternLayout("%d [%t] %-5p %c [%x] <%X{auth}> - %m%n");
            }

            var cfg = Configure.GetConfigSection <Config.Logging>();

            if (cfg != null)
            {
                foreach (var f in typeof(Level).GetFields(BindingFlags.Public | BindingFlags.Static))
                {
                    if (string.Compare(cfg.Threshold, f.Name, true) == 0)
                    {
                        var val = f.GetValue(null);
                        appender.Threshold = val as Level;
                        break;
                    }
                }
            }

            if (appender.Threshold == null)
            {
                appender.Threshold = Level.Debug;
            }

            appender.ActivateOptions();

            log4net.Config.BasicConfigurator.Configure(appender);

            return(config);
        }
コード例 #29
0
ファイル: Configurer.cs プロジェクト: ravikp/NServiceBus
        public static Configure Distributor(this Configure config)
        {
            var msmqTransport = Configure.GetConfigSection <MsmqTransportConfig>();
            var inputQueue    = GetInputQueue(msmqTransport);

            Logger = LogManager.GetLogger(inputQueue + ".distributor");

            var storageQueue          = inputQueue + ".storage";
            var controlQueue          = inputQueue + ".control";
            var applicativeInputQueue = inputQueue + ".worker";

            config.Configurer.ConfigureComponent <ReturnAddressRewriter>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(r => r.DistributorDataQueue, inputQueue);

            Configure.ConfigurationComplete +=
                (o, e) =>
            {
                var bus = Configure.Instance.Builder.Build <UnicastBus>();
                bus.Address = applicativeInputQueue;

                var mgr = new MsmqWorkerAvailabilityManager {
                    StorageQueue = storageQueue
                };

                new ReadyMessageManager
                {
                    WorkerAvailabilityManager = mgr,
                    NumberOfWorkerThreads     = msmqTransport.NumberOfWorkerThreads,
                    ControlQueue = controlQueue
                }.Init();

                new DistributorBootstrapper
                {
                    WorkerAvailabilityManager = mgr,
                    NumberOfWorkerThreads     = msmqTransport.NumberOfWorkerThreads,
                    InputQueue = inputQueue
                }.Init();
            };

            return(config);
        }
コード例 #30
0
        public static Address GetMasterNodeAddress(this Configure config)
        {
            var unicastBusConfig = Configure.GetConfigSection <UnicastBusConfig>();

            //allow users to override data address in config
            if (unicastBusConfig != null && !string.IsNullOrWhiteSpace(unicastBusConfig.DistributorDataAddress))
            {
                return(Address.Parse(unicastBusConfig.DistributorDataAddress));
            }

            var masterNode = GetMasterNode(config);

            if (string.IsNullOrWhiteSpace(masterNode))
            {
                return(Address.Parse(Configure.EndpointName));
            }

            ValidateHostName(masterNode);

            return(new Address(Configure.EndpointName, masterNode));
        }