Пример #1
0
        private static void ValidateMasterNodeConfigurationForWorker(Configure config)
        {
            var masterNodeName = config.GetMasterNode();

            if (masterNodeName == null)
            {
                throw new ConfigurationErrorsException(
                          "When defining Worker profile, 'MasterNodeConfig' section must be defined and the 'Node' entry should point to a valid host name.");
            }

            switch (IsLocalIpAddress(masterNodeName))
            {
            case true:
                Address.InitializeLocalAddress(Address.Local.SubScope(Guid.NewGuid().ToString()).ToString());
                logger.WarnFormat("'MasterNodeConfig.Node' points to a local host name: [{0}]. Worker input address name is [{1}]. It is randomly and uniquely generated to allow multiple workers working from the same machine as the Distributor.", masterNodeName, Address.Local);
                break;

            case false:
                logger.InfoFormat("'MasterNodeConfig.Node' points to a non-local valid host name: [{0}].", masterNodeName);
                break;

            case null:
                throw new ConfigurationErrorsException(
                          string.Format("'MasterNodeConfig.Node' entry should point to a valid host name. Currently it is: [{0}].", masterNodeName));
            }
        }
Пример #2
0
        /// <summary>
        /// Configures Raven 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 configuration:
        /// <code lang="XML" escaped="true">
        ///  <appSettings>
        ///    <!-- Optional overrider for number of requests that each RavenDB session is allowed to make -->
        ///    <add key="NServiceBus/Persistence/RavenDB/MaxNumberOfRequestsPerSession" value="50"/>
        ///  </appSettings>
        ///
        ///  <connectionStrings>
        ///    <!-- Default connection string name -->
        ///    <add name="NServiceBus.Persistence" connectionString="http://localhost:8080" />
        ///  </connectionStrings>
        /// </code>
        /// </example>
        /// <param name="config">The configuration object.</param>
        /// <returns>The configuration object.</returns>
        public static Configure RavenPersistence(this Configure config)
        {
            var connectionStringEntry = ConfigurationManager.ConnectionStrings["NServiceBus.Persistence"];

            //use exisiting config if we can find one
            if (connectionStringEntry != null)
            {
                return(RavenPersistenceWithConnectionString(config, connectionStringEntry.ConnectionString, null));
            }

            var store = new DocumentStore
            {
                Url = RavenPersistenceConstants.DefaultUrl,
                ResourceManagerId = RavenPersistenceConstants.DefaultResourceManagerId,
                DefaultDatabase   = databaseNamingConvention()
            };

            //if we have no master node we should have our own local ravendb
            installRavenIfNeeded = string.IsNullOrEmpty(config.GetMasterNode());

            return(RavenPersistence(config, store));
        }
Пример #3
0
        private static void ValidateMasterNodeConfigurationForWorker(Configure config)
        {
            var masterNodeName = config.GetMasterNode();

            if (masterNodeName == null)
            {
                throw new ConfigurationErrorsException(
                          "When defining Worker profile, 'MasterNodeConfig' section must be defined and the 'Node' entry should point to a valid, non local, host name.");
            }

            if (string.IsNullOrWhiteSpace(masterNodeName))
            {
                throw new ConfigurationErrorsException(
                          string.Format("'MasterNodeConfig.Node' entry should point to a valid, non-local, host name: [{0}].", masterNodeName));
            }

            if (IsLocalIpAddress(masterNodeName))
            {
                throw new ConfigurationErrorsException(
                          string.Format("'MasterNodeConfig.Node' entry should point to a valid, non-local, host name. [{0}] points to a local host address.",
                                        masterNodeName));
            }
        }