/// <summary>
        /// Configures that message bodies should be encrypted/decrypted with a base 64-encoded key from the
        /// &lt;rijndael&gt; element in the Rebus configuration section
        /// </summary>
        public static void EncryptMessageBodies(this DecoratorsConfigurer configurer)
        {
            try
            {
                var section = RebusConfigurationSection.LookItUp();

                var rijndael = section.RijndaelSection;

                if (rijndael == null)
                {
                    throw new ConfigurationErrorsException(string.Format(@"Could not find encryption settings in Rebus configuration section. Did you forget the 'rijndael' element?

{0}", GenerateRijndaelHelp()));
                }

                if (string.IsNullOrEmpty(rijndael.Key))
                {
                    throw new ConfigurationErrorsException(string.Format(@"Could not find key settings in Rijndael element - did you forget the 'key' attribute?

{0}", GenerateRijndaelHelp()));
                }

                EncryptMessageBodies(configurer, rijndael.Key);
            }
            catch (ConfigurationErrorsException e)
            {
                throw new ConfigurationException(
                          @"
An error occurred when trying to parse out the configuration of the RebusConfigurationSection:

{0}

-

For this way of configuring input queue to work, you need to supply a correct configuration
section declaration in the <configSections> element of your app.config/web.config - like so:

    <configSections>
        <section name=""rebus"" type=""Rebus.Configuration.RebusConfigurationSection, Rebus"" />
        <!-- other stuff in here as well -->
    </configSections>

-and then you need a <rebus> element some place further down the app.config/web.config,
like so:

    <rebus inputQueue=""my.service.input.queue"">
        <rijndael key=""base64 encoded key""/>
    </rebus>

Note also, that specifying the input queue name with the 'inputQueue' attribute is optional.

A more full example configuration snippet can be seen here:

{1}
",
                          e, RebusConfigurationSection.ExampleSnippetForErrorMessages);
            }
        }
        public static void UseRabbitMqAndGetInputQueueNameFromAppConfig(this TransportConfigurer configurer, string connectionString)
        {
            try
            {
                var section = RebusConfigurationSection.LookItUp();

                var inputQueueName = section.InputQueue;

                if (string.IsNullOrEmpty(inputQueueName))
                {
                    throw new ConfigurationErrorsException("Could not get input queue name from Rebus configuration section. Did you forget the 'inputQueue' attribute?");
                }

                var errorQueueName = section.ErrorQueue;

                if (string.IsNullOrEmpty(errorQueueName))
                {
                    throw new ConfigurationErrorsException("Could not get input queue name from Rebus configuration section. Did you forget the 'errorQueue' attribute?");
                }

                DoIt(configurer, connectionString, inputQueueName, errorQueueName);
            }
            catch (ConfigurationErrorsException e)
            {
                throw new ConfigurationException(
                          @"
An error occurred when trying to parse out the configuration of the RebusConfigurationSection:

{0}

-

For this way of configuring input queue to work, you need to supply a correct configuration
section declaration in the <configSections> element of your app.config/web.config - like so:

    <configSections>
        <section name=""rebus"" type=""Rebus.Configuration.RebusConfigurationSection, Rebus"" />
        <!-- other stuff in here as well -->
    </configSections>

-and then you need a <rebus> element some place further down the app.config/web.config,
like so:

    <rebus inputQueue=""my.service.input.queue"" errorQueue=""my.service.error.queue"" />

Note also, that specifying the input queue name with the 'inputQueue' attribute is optional.

A more full example configuration snippet can be seen here:

{1}
",
                          e, RebusConfigurationSection.ExampleSnippetForErrorMessages);
            }
        }
        public void CanReadAuditQueueAttribute()
        {
            using (AppConfig.Change(GetPathOf("app.3.config")))
            {
                var section = RebusConfigurationSection.LookItUp();

                section.InputQueue.ShouldBe("input");
                section.ErrorQueue.ShouldBe("error");
                section.AuditQueue.ShouldBe("audit");
            }
        }
        public static RabbitMqOptions UseRabbitMqFromConfigWithLocalName(this RebusTransportConfigurer configurer, string connectionString, string separator)
        {
            var section = RebusConfigurationSection.LookItUp();

            section.VerifyPresenceOfInputQueueConfig();
            section.VerifyPresenceOfErrorQueueConfig();
            var hostname   = GetHostName();
            var inputQueue = string.Format("{0}{2}{1}", section.InputQueue, hostname, separator);
            var errorQueue = string.Format("{0}{2}{1}", section.ErrorQueue, hostname, separator);

            return(configurer.UseRabbitMq(connectionString, inputQueue, errorQueue));
        }
Пример #5
0
        public void CanReadSection_AlsoWorksWhenRijndaelSectionIsOmitted()
        {
            using (AppConfig.Change(GetPathOf("app.2.config")))
            {
                var section = RebusConfigurationSection.LookItUp();

                section.InputQueue.ShouldBe("input");
                section.ErrorQueue.ShouldBe("error");
                section.Workers.ShouldBe(1);

                var rijndaelSection = section.RijndaelSection;
                rijndaelSection.Key.ShouldBe("");
            }
        }
        /// <summary>
        /// Specifies that you want to use Sql Server to both send and receive messages. The input
        /// queue name will be deduced from the Rebus configuration section in the application
        /// configuration file. The input queue will be automatically created if it doesn't exist.
        /// </summary>
        public static SqlServerMessageQueueOptions UseSqlServerAndGetInputQueueNameFromAppConfig(this RebusTransportConfigurer configurer, string connectionStringOrConnectionStringName, string MessageTableName = null)
        {
            try
            {
                string messageTableNameToUse = string.IsNullOrEmpty(MessageTableName) ? DefaultMessagesTableName : MessageTableName;

                var section = RebusConfigurationSection.LookItUp();

                section.VerifyPresenceOfInputQueueConfig();
                section.VerifyPresenceOfErrorQueueConfig();

                var inputQueueName = section.InputQueue;
                var errorQueueName = section.ErrorQueue;

                return(DoIt(connectionStringOrConnectionStringName, configurer, messageTableNameToUse, inputQueueName, errorQueueName));
            }
            catch (ConfigurationErrorsException e)
            {
                throw new ConfigurationException(
                          @"
An error occurred when trying to parse out the configuration of the RebusConfigurationSection:

{0}

-

For this way of configuring input queue to work, you need to supply a correct configuration
section declaration in the <configSections> element of your app.config/web.config - like so:

    <configSections>
        <section name=""rebus"" type=""Rebus.Configuration.RebusConfigurationSection, Rebus"" />
        <!-- other stuff in here as well -->
    </configSections>

-and then you need a <rebus> element some place further down the app.config/web.config,
like so:

    <rebus inputQueue=""my.service.input.queue"" errorQueue=""my.service.error.queue"" />

Note also, that specifying the input queue name with the 'inputQueue' attribute is optional.

A more full example configuration snippet can be seen here:

{1}
",
                          e, RebusConfigurationSection.ExampleSnippetForErrorMessages);
            }
        }
        /// <summary>
        /// Specifies that you want to use the file system to both send and receive messages. The input queue name will be deduced from the Rebus configuration
        /// section in the application configuration file. The input queue will be automatically created if it doesn't exist.
        /// </summary>
        public static void UseTheFileSystemAndGetInputQueueNameFromAppConfig(this RebusTransportConfigurer configurer, string baseDirectory)
        {
            try
            {
                var section = RebusConfigurationSection.LookItUp();

                section.VerifyPresenceOfInputQueueConfig();
                section.VerifyPresenceOfErrorQueueConfig();

                var inputQueueName = section.InputQueue;
                var errorQueueName = section.ErrorQueue;

                DoIt(configurer, baseDirectory, inputQueueName, errorQueueName);
            }
            catch (ConfigurationErrorsException e)
            {
                throw new ConfigurationException(
                          @"
An error occurred when trying to parse out the configuration of the RebusConfigurationSection:

{0}

-

For this way of configuring input queue to work, you need to supply a correct configuration
section declaration in the <configSections> element of your app.config/web.config - like so:

    <configSections>
        <section name=""rebus"" type=""Rebus.Configuration.RebusConfigurationSection, Rebus"" />
        <!-- other stuff in here as well -->
    </configSections>

-and then you need a <rebus> element some place further down the app.config/web.config,
like so:

    <rebus inputQueue=""my_service_input_queue"" errorQueue=""my_service_error_queue"" />

Note also, that specifying the input queue name with the 'inputQueue' attribute is optional.

A more full example configuration snippet can be seen here:

{1}
",
                          e, RebusConfigurationSection.ExampleSnippetForErrorMessages);
            }
        }
        public void CanReadSection()
        {
            using (AppConfig.Change(GetPathOf("app.1.config")))
            {
                var section = RebusConfigurationSection.LookItUp();

                section.InputQueue.ShouldBe("this.is.my.input.queue");
                section.ErrorQueue.ShouldBe("this.is.my.error.queue");
                section.Workers.ShouldBe(5);

                section.Address.ShouldBe("10.0.0.9");

                var rijndaelSection = section.RijndaelSection;
                rijndaelSection.ShouldNotBe(null);
                rijndaelSection.Iv.ShouldBe("OLYKdaDyETlu7NbDMC45dA==");
                rijndaelSection.Key.ShouldBe("oA/ZUnFsR9w1qEatOByBSXc4woCuTxmR99tAuQ56Qko=");
            }
        }
Пример #9
0
        static RabbitMqOptions DoItWithAppConfig(RebusTransportConfigurer configurer, string connectionString, bool ensureExchangeIsDeclared)
        {
            try
            {
                var section = RebusConfigurationSection.LookItUp();

                section.VerifyPresenceOfInputQueueConfig();
                section.VerifyPresenceOfErrorQueueConfig();

                var inputQueueName = section.InputQueue;
                var errorQueueName = section.ErrorQueue;

                return(DoIt(configurer, connectionString, inputQueueName, errorQueueName, ensureExchangeIsDeclared));
            }
            catch (ConfigurationErrorsException e)
            {
                throw new ConfigurationException(
                          @"
An error occurred when trying to parse out the configuration of the RebusConfigurationSection:

{0}

-

For this way of configuring input queue to work, you need to supply a correct configuration section declaration in the <configSections> element of your app.config/web.config - like so:

    <configSections>
        <section name=""rebus"" type=""Rebus.Configuration.RebusConfigurationSection, Rebus"" />
        <!-- other stuff in here as well -->
    </configSections>

-and then you need a <rebus> element some place further down the app.config/web.config, like so:

    <rebus inputQueue=""my.service.input.queue"" errorQueue=""my.service.error.queue"" />

Note also, that specifying the input queue name with the 'inputQueue' attribute is optional.

A more full example configuration snippet can be seen here:

{1}
",
                          e, RebusConfigurationSection.ExampleSnippetForErrorMessages);
            }
        }
Пример #10
0
        public void CanReadSection()
        {
            using (AppConfig.Change(GetPathOf("app.1.config")))
            {
                var section = RebusConfigurationSection.LookItUp();

                section.InputQueue.ShouldBe("this.is.my.input.queue");
                section.ErrorQueue.ShouldBe("this.is.my.error.queue");
                section.TimeoutManagerAddress.ShouldBe("somewhere_else");
                section.Workers.ShouldBe(5);
                section.MaxRetries.ShouldBe(6);

                section.Address.ShouldBe("10.0.0.9");

                var rijndaelSection = section.RijndaelSection;
                rijndaelSection.ShouldNotBe(null);
                rijndaelSection.Key.ShouldBe("oA/ZUnFsR9w1qEatOByBSXc4woCuTxmR99tAuQ56Qko=");
            }
        }
        public static void UseEncryptedMsmqAndGetConfigurationFromAppConfig(this TransportConfigurer configurer)
        {
            try
            {
                var section = RebusConfigurationSection.LookItUp();

                var inputQueueName = section.InputQueue;

                if (string.IsNullOrEmpty(inputQueueName))
                {
                    throw new ConfigurationErrorsException("Could not get input queue name from Rebus configuration section. Did you forget the 'inputQueue' attribute?");
                }

                var errorQueueName = section.ErrorQueue;

                if (string.IsNullOrEmpty(errorQueueName))
                {
                    throw new ConfigurationErrorsException("Could not get error queue name from Rebus configuration section. Did you forget the 'errorQueue' attribute?");
                }

                var rijndael = section.RijndaelSection;

                if (rijndael == null)
                {
                    throw new ConfigurationErrorsException("Could not find encryption settings in Rebus configuration section. Did you forget the 'rijndael' element?");
                }

                if (string.IsNullOrEmpty(rijndael.Iv))
                {
                    throw new ConfigurationErrorsException("Could not find initialization vector settings in Rijndael element - did you forget the 'iv' attribute?");
                }

                if (string.IsNullOrEmpty(rijndael.Key))
                {
                    throw new ConfigurationErrorsException("Could not find key settings in Rijndael element - did you forget the 'key' attribute?");
                }

                DoItEncrypted(configurer, inputQueueName, rijndael.Iv, rijndael.Key, errorQueueName);
            }
            catch (ConfigurationErrorsException e)
            {
                throw new ConfigurationException(
                          @"
An error occurred when trying to parse out the configuration of the RebusConfigurationSection:

{0}

-

For this way of configuring input queue to work, you need to supply a correct configuration
section declaration in the <configSections> element of your app.config/web.config - like so:

    <configSections>
        <section name=""rebus"" type=""Rebus.Configuration.RebusConfigurationSection, Rebus"" />
        <!-- other stuff in here as well -->
    </configSections>

-and then you need a <rebus> element some place further down the app.config/web.config,
like so:

    <rebus InputQueue=""my.service.input.queue"">
        <rijndael iv=""initialization vector here"" key=""key here""/>
    </rebus>

Note also, that specifying the input queue name with the 'inputQueue' attribute is optional.

A more full example configuration snippet can be seen here:

{1}
",
                          e, RebusConfigurationSection.ExampleSnippetForErrorMessages);
            }
        }